Debian Codegraph @

src/org/stathissideris/ascii2image/core/ConversionOptions.java

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 /**
2 * ditaa - Diagrams Through Ascii Art
3 *
•4 * Copyright (C) 2004-2011 Efstathios Sideris
5 *
•6 * ditaa is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
•11 * ditaa is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
•14 * GNU Lesser General Public License for more details.
15 *
•16 * You should have received a copy of the GNU Lesser General Public
17 * License along with ditaa. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20 package org.stathissideris.ascii2image.core;
21
•22 //import org.apache.commons.cli.CommandLine;
23 //import org.apache.commons.cli.Option;
24 //import org.stathissideris.ascii2image.graphics.CustomShapeDefinition;
25 //import org.xml.sax.SAXException;
26
27 //import javax.xml.parsers.ParserConfigurationException;
28 //import java.awt.*;
29 //import java.io.File;
30 //import java.io.IOException;
31 //import java.io.UnsupportedEncodingException;
32 //import java.util.HashMap;
33
34 /**
35 *
36 * @author Efstathios Sideris
37 */
38 public class ConversionOptions {
39
•40 public ProcessingOptions processingOptions =
41 new ProcessingOptions();
42 public RenderingOptions renderingOptions =
43 new RenderingOptions();
44
45 public void setDebug(boolean value){
•46 processingOptions.setPrintDebugOutput(value);
47 renderingOptions.setRenderDebugLines(value);
48 }
49
50 public ConversionOptions(){}
51
52 public void setDropShadows(boolean dropShadows) {
53 renderingOptions.setDropShadows(dropShadows);
54 }
•55
56 // /** Parse a color from a 6- or 8-digit hex string. For example, FF0000 is red.
57 // * If eight digits, last two digits are alpha. */
58 // public static Color parseColor(String hexString) {
59 // if(hexString.length() == 6) {
60 // return new Color(Integer.parseInt(hexString, 16));
61 // } else if(hexString.length() == 8) {
62 // return new Color(
63 // Integer.parseInt(hexString.substring(0,2), 16),
64 // Integer.parseInt(hexString.substring(2,4), 16),
65 // Integer.parseInt(hexString.substring(4,6), 16),
66 // Integer.parseInt(hexString.substring(6,8), 16)
67 // );
68 // } else {
69 // throw new IllegalArgumentException("Cannot interpret \""+hexString+"\" as background colour. It needs to be a 6- or 8-digit hex number, depending on whether you have transparency or not (same as HTML).");
70 // }
71 // }
72 //
73 // public ConversionOptions(CommandLine cmdLine) throws UnsupportedEncodingException{
74 //
75 // processingOptions.setVerbose(cmdLine.hasOption("verbose"));
76 // renderingOptions.setDropShadows(!cmdLine.hasOption("no-shadows"));
77 // this.setDebug(cmdLine.hasOption("debug"));
78 // processingOptions.setOverwriteFiles(cmdLine.hasOption("overwrite"));
79 //
80 // if(cmdLine.hasOption("scale")){
81 // Float scale = Float.parseFloat(cmdLine.getOptionValue("scale"));
82 // renderingOptions.setScale(scale.floatValue());
83 // }
84 //
85 // processingOptions.setAllCornersAreRound(cmdLine.hasOption("round-corners"));
86 // processingOptions.setPerformSeparationOfCommonEdges(!cmdLine.hasOption("no-separation"));
87 // renderingOptions.setAntialias(!cmdLine.hasOption("no-antialias"));
•88 // renderingOptions.setFixedSlope(cmdLine.hasOption("fixed-slope"));
89 //
•90 // if(cmdLine.hasOption("background")) {
91 // String b = cmdLine.getOptionValue("background");
92 // Color background = parseColor(b);
93 // renderingOptions.setBackgroundColor(background);
94 // }
95 //
96 // if(cmdLine.hasOption("transparent")) {
97 // renderingOptions.setBackgroundColor(new Color(0,0,0,0));
98 // }
99 //
100 // if(cmdLine.hasOption("tabs")){
101 // Integer tabSize = Integer.parseInt(cmdLine.getOptionValue("tabs"));
102 // int tabSizeValue = tabSize.intValue();
103 // if(tabSizeValue < 0) tabSizeValue = 0;
104 // processingOptions.setTabSize(tabSizeValue);
105 // }
106 //
107 // String encoding = (String) cmdLine.getOptionValue("encoding");
108 // if(encoding != null){
109 // new String(new byte[2], encoding);
110 // processingOptions.setCharacterEncoding(encoding);
111 // }
112 //
•113 // if (cmdLine.hasOption("svg")){
114 // renderingOptions.setImageType(RenderingOptions.ImageType.SVG);
115 // }
116 //
117 // if (cmdLine.hasOption("svg-font-url")){
118 // renderingOptions.setFontURL(cmdLine.getOptionValue("svg-font-url"));
119 // }
120 //
121 // ConfigurationParser configParser = new ConfigurationParser();
122 // try {
123 // for (Option curOption : cmdLine.getOptions()) {
124 // if(curOption.getLongOpt().equals("config")) {
125 // String configFilename = curOption.getValue();
126 // System.out.println("Parsing configuration file "+configFilename);
127 // File file = new File(configFilename);
128 // if(file.exists()){
129 // configParser.parseFile(file);
130 // HashMap<String, CustomShapeDefinition> shapes = configParser.getShapeDefinitionsHash();
131 // processingOptions.putAllInCustomShapes(shapes);
132 // } else {
133 // System.err.println("File "+file+" does not exist, skipping");
134 // }
135 // }
136 // }
137 // } catch (ParserConfigurationException e) {
138 // // TODO Auto-generated catch block
139 // e.printStackTrace();
140 // } catch (SAXException e) {
141 // // TODO Auto-generated catch block
142 // e.printStackTrace();
143 // } catch (IOException e) {
144 // // TODO Auto-generated catch block
145 // e.printStackTrace();
146 // }
147 // }
148 }
149
150
151 // may be supported at a later date:
152 //String exportFormat = (String) cmdLine.getOptionValue("format");
153 //if(exportFormat != null){
154 // exportFormat = exportFormat.toLowerCase();
155 // if(exportFormat == "jpeg" || exportFormat == "jpg"){
156 // processingOptions.setExportFormat(ProcessingOptions.FORMAT_JPEG);
157 // } else if(exportFormat == "png"){
158 // processingOptions.setExportFormat(ProcessingOptions.FORMAT_PNG);
159 // } else if(exportFormat == "gif"){
160 // processingOptions.setExportFormat(ProcessingOptions.FORMAT_GIF);
161 // }
162 //}
163 //
164 //String colorCodeMode = (String) cmdLine.getOptionValue("color-codes");
165 //if(colorCodeMode != null){
166 // if(colorCodeMode.equals("use"))
167 // processingOptions.setColorCodesProcessingMode(ProcessingOptions.USE_COLOR_CODES);
168 // else if(colorCodeMode.equals("ignore"))
169 // processingOptions.setColorCodesProcessingMode(ProcessingOptions.IGNORE_COLOR_CODES);
170 // else if(colorCodeMode.equals("render"))
171 // processingOptions.setColorCodesProcessingMode(ProcessingOptions.RENDER_COLOR_CODES);
172 //}
173 //
174 //String tagsMode = (String) cmdLine.getOptionValue("tags");
175 //if(tagsMode != null){
176 // if(tagsMode.equals("use"))
177 // processingOptions.setTagProcessingMode(ProcessingOptions.USE_TAGS);
178 // else if(tagsMode.equals("ignore"))
179 // processingOptions.setTagProcessingMode(ProcessingOptions.IGNORE_TAGS);
180 // else if(tagsMode.equals("render"))
181 // processingOptions.setTagProcessingMode(ProcessingOptions.RENDER_TAGS);
182 //}
183 //
184 //
185 //String markupMode = (String) cmdLine.getOptionValue("markup");
186 //if(markupMode != null){
187 // if(markupMode.equals("use")){
188 // processingOptions.setColorCodesProcessingMode(ProcessingOptions.USE_COLOR_CODES);
189 // processingOptions.setTagProcessingMode(ProcessingOptions.USE_TAGS);
190 // } else if(markupMode.equals("ignore")){
191 // processingOptions.setColorCodesProcessingMode(ProcessingOptions.IGNORE_COLOR_CODES);
192 // processingOptions.setTagProcessingMode(ProcessingOptions.IGNORE_TAGS);
193 // } else if(markupMode.equals("render")){
194 // processingOptions.setColorCodesProcessingMode(ProcessingOptions.RENDER_COLOR_CODES);
195 // processingOptions.setTagProcessingMode(ProcessingOptions.RENDER_TAGS);
196 // }
•197 //}