001    package org.jgnuplot;
002    
003    /**
004     * This class models all possible values for the line style option for a graph
005     * in a plot command.
006     * 
007     * @author Pander
008     */
009    public final class LineType {
010       private LineType() {
011       }
012    
013       public static final int NOT_SPECIFIED = -2;
014       /**
015        * <font face="Courier New, courier" color="#000000">===========</font> is a
016        * black solid bold line on screen.
017        */
018       public static final int SCREEN_BLACK_SOLID_BOLD = -1;
019       /**
020        * <font face="Courier New, courier" color="#000000">. . . . .</font> is a
021        * black dotted line on screen.
022        */
023       public static final int SCREEN_BLACK_DOTS = 0;
024       /**
025        * <font face="Courier New, courier" color="#ff0000">___________</font> is a
026        * red solid line on screen.
027        */
028       public static final int SCREEN_RED = 1;
029       /**
030        * <font face="Courier New, courier" color="#00ff00">___________</font> is a
031        * green solid line on screen.
032        */
033       public static final int SCREEN_GREEN = 2;
034       /**
035        * <font face="Courier New, courier" color="#0000ff">___________</font> is a
036        * blue solid line on screen.
037        */
038       public static final int SCREEN_BLUE = 3;
039       /**
040        * <font face="Courier New, courier" color="#00ffff">___________</font> is a
041        * magenta solid line on screen.
042        */
043       public static final int SCREEN_MAGENTA = 4;
044       /**
045        * <font face="Courier New, courier" color="#ff00ff">___________</font> is a
046        * cyan solid line on screen.
047        */
048       public static final int SCREEN_CYAN = 5;
049       /**
050        * <font face="Courier New, courier" color="#a0522d">___________</font> is a
051        * brown solid line on screen.
052        */
053       public static final int SCREEN_BROWN = 6;
054       /**
055        * <font face="Courier New, courier" color="#ffa500">___________</font> is
056        * yellow solid line on screen.
057        */
058       public static final int SCREEN_YELLOW = 7;
059       /**
060        * <font face="Courier New, courier" color="#ff7f50">___________</font> is
061        * salmon solid line on screen.
062        */
063       public static final int SCREEN_SALMON = 8;
064       /**
065        * <font face="Courier New, courier">=========</font> is solid bold line on
066        * screen.
067        */
068       public static final int POSTSCRIPT_SOLID_BOLD = -1;
069       /**
070        * <font face="Courier New, courier">. . . . .</font> is a 'dot space' line
071        * in PostScript.
072        */
073       public static final int POSTSCRIPT_DOT_SPACE = 0;
074       /**
075        * <font face="Courier New, courier">_________</font> is a solid line in
076        * PostScript.
077        */
078       public static final int POSTSCRIPT_SOLID = 1;
079       /**
080        * <font face="Courier New, courier">---------</font> is a dashed line in
081        * PostScript.
082        */
083       public static final int POSTSCRIPT_DASHES = 2;
084       /**
085        * <font face="Courier New, courier">- - - - -</font> is a 'dash space' line
086        * in PostScript.
087        */
088       public static final int POSTSCRIPT_DASH_SPACE = 3;
089       /**
090        * <font face="Courier New, courier">.........</font> is a dotted line in
091        * PostScript.
092        */
093       public static final int POSTSCRIPT_DOTS = 4;
094       /**
095        * <font face="Courier New, courier">-.-.-.-.-</font> is a 'dash dot' line
096        * in PostScript.
097        */
098       public static final int POSTSCRIPT_DASH_DOT = 5;
099       /**
100        * <font face="Courier New, courier">- . - . -</font> is a 'dash space dot
101        * space' line in PostScript.
102        */
103       public static final int POSTSCRIPT_DASH_SPACE_DOT_SPACE = 6;
104       /**
105        * <font face="Courier New, courier">-- -- -- </font> is a 'dash dash space'
106        * line in PostScript.
107        */
108       public static final int POSTSCRIPT_DASH_DASH_SPACE = 7;
109       /**
110        * <font face="Courier New, courier">--- --- </font> is a 'dash dash dash
111        * space' line in PostScript.
112        */
113       public static final int POSTSCRIPT_DASH_DASH_DASH_SPACE = 8;
114       /**
115        * <font face="Courier New, courier">---- ----</font> is a 'dash dash dash
116        * dash space' line in PostScript.
117        */
118       public static final int POSTSCRIPT_DASH_DASH_DASH_DASH_SPACE = 9;
119    
120       /**
121        * This method converts screen line type to PostScript line type because the
122        * underlying integer values are not identical.
123        * 
124        * @param theLineType
125        *           screen line type
126        * @return postscript line type.
127        */
128       public static int convertScreenToPostscript(int theLineType) {
129          switch (theLineType) {
130          case SCREEN_BLACK_SOLID_BOLD:
131             return POSTSCRIPT_SOLID;
132          default:
133             return POSTSCRIPT_SOLID; // TODO not all are covered
134          }
135       }
136    
137       /**
138        * This method converts PostScript line type to screen line type because the
139        * underlying integer values are not identical.
140        * 
141        * @param theLineType
142        *           PostScript line type
143        * @return screen line type.
144        */
145       public static int convertPostscriptToScreen(int theLineType) {
146          switch (theLineType) {
147          case POSTSCRIPT_SOLID:
148             return SCREEN_BLACK_SOLID_BOLD;
149          default:
150             return SCREEN_BLACK_SOLID_BOLD; // TODO not all are covered
151          }
152       }
153    }