001    package org.jgnuplot;
002    
003    /**
004     * This class models all possible values for the point style option for a graph
005     * in a plot command.
006     * 
007     * @author Pander
008     */
009    public final class PointType {
010       private PointType() {
011       }
012    
013       public static final int NOT_SPECIFIED = -2;
014    
015       public static final int SCREEN_NONE = -1;
016    
017       public static final int SCREEN_DOT = 0;
018    
019       public static final int SCREEN_PLUS = 1;
020    
021       public static final int SCREEN_X = 2;
022    
023       public static final int SCREEN_STAR = 3;
024    
025       public static final int SCREEN_SQUARE_DOT = 4;
026    
027       public static final int SCREEN_SQUARE_FILLED = 5;
028    
029       public static final int SCREEN_CIRCLE_DOT = 6;
030    
031       public static final int SCREEN_CIRCLE_FILLED = 7;
032    
033       public static final int SCREEN_TRIANGLE_UP_DOT = 8;
034    
035       public static final int SCREEN_TRIANGLE_UP_FILLED = 9;
036    
037       public static final int SCREEN_TRIANGLE_DOWN_DOT = 10;
038    
039       public static final int SCREEN_TRIANGLE_DOWN_FILLED = 11;
040    
041       public static final int SCREEN_DIAMOND_DOT = 12;
042    
043       public static final int SCREEN_DIAMOND_FILLED = 13;
044    
045       public static final int POSTSCRIPT_DOT = -1;
046    
047       public static final int POSTSCRIPT_DOT_SMALL = 0;
048    
049       public static final int POSTSCRIPT_PLUS = 1;
050    
051       public static final int POSTSCRIPT_X = 2;
052    
053       public static final int POSTSCRIPT_STAR = 3;
054    
055       public static final int POSTSCRIPT_SQUARE_DOT = 4;
056    
057       public static final int POSTSCRIPT_SQUARE_FILLED = 5;
058    
059       public static final int POSTSCRIPT_CIRCLE_DOT = 6;
060    
061       public static final int POSTSCRIPT_CIRCLE_FILLED = 7;
062    
063       public static final int POSTSCRIPT_TRIANGLE_UP_DOT = 8;
064    
065       public static final int POSTSCRIPT_TRIANGLE_UP_FILLED = 9;
066    
067       public static final int POSTSCRIPT_TRIANGLE_DOWN_DOT = 10;
068    
069       public static final int POSTSCRIPT_TRIANGLE_DOWN_FILLED = 11;
070    
071       public static final int POSTSCRIPT_DIAMOND_DOT = 12;
072    
073       public static final int POSTSCRIPT_DIAMOND_FILLED = 13;
074    
075       public static final int POSTSCRIPT_PENTAGON_DOT = 14;
076    
077       public static final int POSTSCRIPT_PENTAGON_FILLED = 15;
078    
079       // TODO POSTSCRIPT 16 - 74
080    
081       /**
082        * This method converts screen point type to PostScript point type because
083        * the underlying integer values are not identical.
084        * 
085        * @param thePointType
086        *           screen point type
087        * @return postscript point type.
088        */
089       public static int convertScreenToPostscript(int thePointType) {
090          switch (thePointType) {
091          case SCREEN_DOT:
092             return POSTSCRIPT_DOT;
093          case SCREEN_PLUS:
094             return POSTSCRIPT_PLUS;
095          case SCREEN_X:
096             return POSTSCRIPT_X;
097          case SCREEN_STAR:
098             return POSTSCRIPT_STAR;
099          case SCREEN_SQUARE_DOT:
100             return POSTSCRIPT_SQUARE_DOT;
101          case SCREEN_SQUARE_FILLED:
102             return POSTSCRIPT_SQUARE_FILLED;
103          case SCREEN_CIRCLE_DOT:
104             return POSTSCRIPT_CIRCLE_DOT;
105          case SCREEN_CIRCLE_FILLED:
106             return POSTSCRIPT_CIRCLE_FILLED;
107          case SCREEN_TRIANGLE_DOWN_DOT:
108             return POSTSCRIPT_TRIANGLE_DOWN_DOT;
109          case SCREEN_TRIANGLE_DOWN_FILLED:
110             return POSTSCRIPT_TRIANGLE_DOWN_FILLED;
111          case SCREEN_TRIANGLE_UP_DOT:
112             return POSTSCRIPT_TRIANGLE_UP_DOT;
113          case SCREEN_TRIANGLE_UP_FILLED:
114             return POSTSCRIPT_TRIANGLE_UP_FILLED;
115          case SCREEN_DIAMOND_DOT:
116             return POSTSCRIPT_DIAMOND_DOT;
117          case SCREEN_DIAMOND_FILLED:
118             return POSTSCRIPT_DIAMOND_FILLED;
119          default:
120             return POSTSCRIPT_DOT; // TODO not all are covered
121          }
122       }
123    
124       /**
125        * This method converts PostScript point type to screen point type because
126        * the underlying integer values are not identical.
127        * 
128        * @param thePointType
129        *           PostScript point type
130        * 
131        * @return screen point type.
132        */
133       public static int convertPostscriptToScreen(int thePointType) {
134          switch (thePointType) {
135          case POSTSCRIPT_DOT:
136             return SCREEN_DOT;
137          case POSTSCRIPT_PLUS:
138             return SCREEN_PLUS;
139          case POSTSCRIPT_X:
140             return SCREEN_X;
141          case POSTSCRIPT_STAR:
142             return SCREEN_STAR;
143          case POSTSCRIPT_SQUARE_DOT:
144             return SCREEN_SQUARE_DOT;
145          case POSTSCRIPT_SQUARE_FILLED:
146             return SCREEN_SQUARE_FILLED;
147          case POSTSCRIPT_CIRCLE_DOT:
148             return SCREEN_CIRCLE_DOT;
149          case POSTSCRIPT_CIRCLE_FILLED:
150             return SCREEN_CIRCLE_FILLED;
151          case POSTSCRIPT_TRIANGLE_DOWN_DOT:
152             return SCREEN_TRIANGLE_DOWN_DOT;
153          case POSTSCRIPT_TRIANGLE_DOWN_FILLED:
154             return SCREEN_TRIANGLE_DOWN_FILLED;
155          case POSTSCRIPT_TRIANGLE_UP_DOT:
156             return SCREEN_TRIANGLE_UP_DOT;
157          case POSTSCRIPT_TRIANGLE_UP_FILLED:
158             return SCREEN_TRIANGLE_UP_FILLED;
159          case POSTSCRIPT_DIAMOND_DOT:
160             return SCREEN_DIAMOND_DOT;
161          case POSTSCRIPT_DIAMOND_FILLED:
162             return SCREEN_DIAMOND_FILLED;
163          default:
164             return SCREEN_DOT; // TODO not all are covered
165          }
166       }
167    }