| 1 |
/* |
| 2 |
* DiTAA - Diagrams Through Ascii Art |
| 3 |
* |
| 4 |
* Copyright (C) 2004 Efstathios Sideris |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU General Public License |
| 8 |
* as published by the Free Software Foundation; either version 2 |
| 9 |
* of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This program 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 General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 |
* |
| 20 |
*/ |
| 21 |
package org.stathissideris.ascii2image.core; |
| 22 |
|
| 23 |
|
| 24 |
/** |
| 25 |
* |
| 26 |
* @author Efstathios Sideris |
| 27 |
*/ |
| 28 |
public class ConversionOptions { |
| 29 |
|
| 30 |
// public ProcessingOptions processingOptions = |
| 31 |
// new ProcessingOptions(); |
| 32 |
public RenderingOptions renderingOptions = |
| 33 |
new RenderingOptions(); |
| 34 |
|
| 35 |
public void setDebug(boolean value){ |
| 36 |
// processingOptions.setPrintDebugOutput(value); |
| 37 |
renderingOptions.setRenderDebugLines(value); |
| 38 |
} |
| 39 |
|
| 40 |
public ConversionOptions(){} |
| 41 |
|
| 42 |
public void setDropShadows(boolean dropShadows) { |
| 43 |
renderingOptions.setDropShadows(dropShadows); |
| 44 |
} |
| 45 |
|
| 46 |
// public ConversionOptions(CommandLine cmdLine) throws UnsupportedEncodingException{ |
| 47 |
// |
| 48 |
// processingOptions.setVerbose(cmdLine.hasOption("verbose")); |
| 49 |
// renderingOptions.setDropShadows(!cmdLine.hasOption("no-shadows")); |
| 50 |
// this.setDebug(cmdLine.hasOption("debug")); |
| 51 |
// processingOptions.setOverwriteFiles(cmdLine.hasOption("overwrite")); |
| 52 |
// |
| 53 |
// if(cmdLine.hasOption("scale")){ |
| 54 |
// Float scale = Float.parseFloat(cmdLine.getOptionValue("scale")); |
| 55 |
// renderingOptions.setScale(scale.floatValue()); |
| 56 |
// } |
| 57 |
// |
| 58 |
// processingOptions.setAllCornersAreRound(cmdLine.hasOption("round-corners")); |
| 59 |
// processingOptions.setPerformSeparationOfCommonEdges(!cmdLine.hasOption("no-separation")); |
| 60 |
// renderingOptions.setAntialias(!cmdLine.hasOption("no-antialias")); |
| 61 |
// |
| 62 |
// |
| 63 |
// |
| 64 |
// if(cmdLine.hasOption("tabs")){ |
| 65 |
// Integer tabSize = Integer.parseInt(cmdLine.getOptionValue("tabs")); |
| 66 |
// int tabSizeValue = tabSize.intValue(); |
| 67 |
// if(tabSizeValue < 0) tabSizeValue = 0; |
| 68 |
// processingOptions.setTabSize(tabSizeValue); |
| 69 |
// } |
| 70 |
// |
| 71 |
// String encoding = (String) cmdLine.getOptionValue("encoding"); |
| 72 |
// if(encoding != null){ |
| 73 |
// new String(new byte[2], encoding); |
| 74 |
// processingOptions.setCharacterEncoding(encoding); |
| 75 |
// } |
| 76 |
// |
| 77 |
// ConfigurationParser configParser = new ConfigurationParser(); |
| 78 |
// try { |
| 79 |
// for (Option curOption : cmdLine.getOptions()) { |
| 80 |
// if(curOption.getLongOpt().equals("config")) { |
| 81 |
// String configFilename = curOption.getValue(); |
| 82 |
// System.out.println("Parsing configuration file "+configFilename); |
| 83 |
// File file = new File(configFilename); |
| 84 |
// if(file.exists()){ |
| 85 |
// configParser.parseFile(file); |
| 86 |
// HashMap<String, CustomShapeDefinition> shapes = configParser.getShapeDefinitionsHash(); |
| 87 |
// processingOptions.putAllInCustomShapes(shapes); |
| 88 |
// } else { |
| 89 |
// System.err.println("File "+file+" does not exist, skipping"); |
| 90 |
// } |
| 91 |
// } |
| 92 |
// } |
| 93 |
// } catch (ParserConfigurationException e) { |
| 94 |
// // TODO Auto-generated catch block |
| 95 |
// e.printStackTrace(); |
| 96 |
// } catch (SAXException e) { |
| 97 |
// // TODO Auto-generated catch block |
| 98 |
// e.printStackTrace(); |
| 99 |
// } catch (IOException e) { |
| 100 |
// // TODO Auto-generated catch block |
| 101 |
// e.printStackTrace(); |
| 102 |
// } |
| 103 |
// } |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
// may be supported at a later date: |
| 108 |
//String exportFormat = (String) cmdLine.getOptionValue("format"); |
| 109 |
//if(exportFormat != null){ |
| 110 |
// exportFormat = exportFormat.toLowerCase(); |
| 111 |
// if(exportFormat == "jpeg" || exportFormat == "jpg"){ |
| 112 |
// processingOptions.setExportFormat(ProcessingOptions.FORMAT_JPEG); |
| 113 |
// } else if(exportFormat == "png"){ |
| 114 |
// processingOptions.setExportFormat(ProcessingOptions.FORMAT_PNG); |
| 115 |
// } else if(exportFormat == "gif"){ |
| 116 |
// processingOptions.setExportFormat(ProcessingOptions.FORMAT_GIF); |
| 117 |
// } |
| 118 |
//} |
| 119 |
// |
| 120 |
//String colorCodeMode = (String) cmdLine.getOptionValue("color-codes"); |
| 121 |
//if(colorCodeMode != null){ |
| 122 |
// if(colorCodeMode.equals("use")) |
| 123 |
// processingOptions.setColorCodesProcessingMode(ProcessingOptions.USE_COLOR_CODES); |
| 124 |
// else if(colorCodeMode.equals("ignore")) |
| 125 |
// processingOptions.setColorCodesProcessingMode(ProcessingOptions.IGNORE_COLOR_CODES); |
| 126 |
// else if(colorCodeMode.equals("render")) |
| 127 |
// processingOptions.setColorCodesProcessingMode(ProcessingOptions.RENDER_COLOR_CODES); |
| 128 |
//} |
| 129 |
// |
| 130 |
//String tagsMode = (String) cmdLine.getOptionValue("tags"); |
| 131 |
//if(tagsMode != null){ |
| 132 |
// if(tagsMode.equals("use")) |
| 133 |
// processingOptions.setTagProcessingMode(ProcessingOptions.USE_TAGS); |
| 134 |
// else if(tagsMode.equals("ignore")) |
| 135 |
// processingOptions.setTagProcessingMode(ProcessingOptions.IGNORE_TAGS); |
| 136 |
// else if(tagsMode.equals("render")) |
| 137 |
// processingOptions.setTagProcessingMode(ProcessingOptions.RENDER_TAGS); |
| 138 |
//} |
| 139 |
// |
| 140 |
// |
| 141 |
//String markupMode = (String) cmdLine.getOptionValue("markup"); |
| 142 |
//if(markupMode != null){ |
| 143 |
// if(markupMode.equals("use")){ |
| 144 |
// processingOptions.setColorCodesProcessingMode(ProcessingOptions.USE_COLOR_CODES); |
| 145 |
// processingOptions.setTagProcessingMode(ProcessingOptions.USE_TAGS); |
| 146 |
// } else if(markupMode.equals("ignore")){ |
| 147 |
// processingOptions.setColorCodesProcessingMode(ProcessingOptions.IGNORE_COLOR_CODES); |
| 148 |
// processingOptions.setTagProcessingMode(ProcessingOptions.IGNORE_TAGS); |
| 149 |
// } else if(markupMode.equals("render")){ |
| 150 |
// processingOptions.setColorCodesProcessingMode(ProcessingOptions.RENDER_COLOR_CODES); |
| 151 |
// processingOptions.setTagProcessingMode(ProcessingOptions.RENDER_TAGS); |
| 152 |
// } |
| 153 |
//} |