~ubuntu-branches/debian/sid/geogebra/sid

« back to all changes in this revision

Viewing changes to geogebra/kernel/AlgoCenterConic.java

  • Committer: Package Import Robot
  • Author(s): Giovanni Mascellani
  • Date: 2012-01-10 11:37:41 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120110113741-satwohsd4de4ite1
Tags: 4.0.19.0+dfsg1-1
* New upstream version (closes: #649893).
* Update dependency: icedtea-plugin -> icedtea-netx-common (LP: #893007).
* New thumbnailer configuration compatible with Gnome 3.
* Package building is now managed by javahelper instead of upstream
  build.xml.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
GeoGebra - Dynamic Mathematics for Everyone
3
 
http://www.geogebra.org
4
 
 
5
 
This file is part of GeoGebra.
6
 
 
7
 
This program is free software; you can redistribute it and/or modify it 
8
 
under the terms of the GNU General Public License as published by 
9
 
the Free Software Foundation.
10
 
 
11
 
*/
12
 
 
13
 
/*
14
 
 * AlgoMidpointConic.java
15
 
 *
16
 
 * Created on 11. November 2001, 21:37
17
 
 */
18
 
 
19
 
package geogebra.kernel;
20
 
 
21
 
 
22
 
/**
23
 
 * Center of a conic section. 
24
 
 */
25
 
public class AlgoCenterConic extends AlgoElement {
26
 
 
27
 
    /**
28
 
         * 
29
 
         */
30
 
        private static final long serialVersionUID = 1L;
31
 
        private GeoConic c; // input
32
 
    private GeoPoint midpoint; // output                 
33
 
 
34
 
    AlgoCenterConic(Construction cons, String label, GeoConic c) {
35
 
        super(cons);
36
 
        this.c = c;
37
 
        midpoint = new GeoPoint(cons);
38
 
        setInputOutput(); // for AlgoElement
39
 
 
40
 
        compute();
41
 
        midpoint.setLabel(label);
42
 
    }
43
 
 
44
 
    protected String getClassName() {
45
 
        return "AlgoCenterConic";
46
 
    }
47
 
 
48
 
    // for AlgoElement
49
 
    protected void setInputOutput() {
50
 
        input = new GeoElement[1];
51
 
        input[0] = c;
52
 
 
53
 
        output = new GeoElement[1];
54
 
        output[0] = midpoint;
55
 
        setDependencies(); // done by AlgoElement
56
 
    }
57
 
 
58
 
    GeoConic getConic() {
59
 
        return c;
60
 
    }
61
 
    GeoPoint getPoint() {
62
 
        return midpoint;
63
 
    }
64
 
 
65
 
    protected final void compute() {
66
 
        if (!c.isDefined()) {
67
 
            midpoint.setUndefined();
68
 
            return;
69
 
        }
70
 
 
71
 
        switch (c.type) {
72
 
            case GeoConic.CONIC_CIRCLE :
73
 
            case GeoConic.CONIC_ELLIPSE :
74
 
            case GeoConic.CONIC_HYPERBOLA :
75
 
            case GeoConic.CONIC_SINGLE_POINT :
76
 
            case GeoConic.CONIC_INTERSECTING_LINES :
77
 
                midpoint.setCoords(c.b.x, c.b.y, 1.0d);
78
 
                break;
79
 
 
80
 
            default :
81
 
                // midpoint undefined
82
 
                midpoint.setUndefined();
83
 
        }
84
 
    }
85
 
 
86
 
    final public String toString() {
87
 
        StringBuffer sb = new StringBuffer();
88
 
        // Michael Borcherds 2008-03-30
89
 
        // simplified to allow better Chinese translation
90
 
        sb.append(app.getPlain("CenterOfA",c.getLabel()));
91
 
 
92
 
        return sb.toString();
93
 
    }
94
 
}
 
1
/* 
 
2
GeoGebra - Dynamic Mathematics for Everyone
 
3
http://www.geogebra.org
 
4
 
 
5
This file is part of GeoGebra.
 
6
 
 
7
This program is free software; you can redistribute it and/or modify it 
 
8
under the terms of the GNU General Public License as published by 
 
9
the Free Software Foundation.
 
10
 
 
11
*/
 
12
 
 
13
/*
 
14
 * AlgoMidpointConic.java
 
15
 *
 
16
 * Created on 11. November 2001, 21:37
 
17
 */
 
18
 
 
19
package geogebra.kernel;
 
20
 
 
21
import geogebra.euclidian.EuclidianConstants;
 
22
 
 
23
 
 
24
/**
 
25
 * Center of a conic section. 
 
26
 */
 
27
public class AlgoCenterConic extends AlgoElement {
 
28
 
 
29
    /**
 
30
         * 
 
31
         */
 
32
        private static final long serialVersionUID = 1L;
 
33
        private GeoConic c; // input
 
34
    private GeoPoint midpoint; // output                 
 
35
 
 
36
    AlgoCenterConic(Construction cons, String label, GeoConic c) {
 
37
        super(cons);
 
38
        this.c = c;
 
39
        midpoint = new GeoPoint(cons);
 
40
        setInputOutput(); // for AlgoElement
 
41
 
 
42
        compute();
 
43
        midpoint.setLabel(label);
 
44
    }
 
45
 
 
46
    public String getClassName() {
 
47
        return "AlgoCenterConic";
 
48
    }
 
49
 
 
50
    public int getRelatedModeID() {
 
51
        return EuclidianConstants.MODE_MIDPOINT;
 
52
    }
 
53
    
 
54
    // for AlgoElement
 
55
    protected void setInputOutput() {
 
56
        input = new GeoElement[1];
 
57
        input[0] = c;
 
58
 
 
59
        output = new GeoElement[1];
 
60
        output[0] = midpoint;
 
61
        setDependencies(); // done by AlgoElement
 
62
    }
 
63
 
 
64
    GeoConic getConic() {
 
65
        return c;
 
66
    }
 
67
    GeoPoint getPoint() {
 
68
        return midpoint;
 
69
    }
 
70
 
 
71
    protected final void compute() {
 
72
        if (!c.isDefined()) {
 
73
            midpoint.setUndefined();
 
74
            return;
 
75
        }
 
76
 
 
77
        switch (c.type) {
 
78
            case GeoConic.CONIC_CIRCLE :
 
79
            case GeoConic.CONIC_ELLIPSE :
 
80
            case GeoConic.CONIC_HYPERBOLA :
 
81
            case GeoConic.CONIC_SINGLE_POINT :
 
82
            case GeoConic.CONIC_INTERSECTING_LINES :
 
83
                midpoint.setCoords(c.b.x, c.b.y, 1.0d);
 
84
                break;
 
85
 
 
86
            default :
 
87
                // midpoint undefined
 
88
                midpoint.setUndefined();
 
89
        }
 
90
    }
 
91
 
 
92
    final public String toString() {
 
93
        // Michael Borcherds 2008-03-30
 
94
        // simplified to allow better Chinese translation
 
95
        return app.getPlain("CenterOfA",c.getLabel());
 
96
    }
 
97
}