Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject stathissideris/ditaa "0.11.0"
(defproject stathissideris/ditaa "0.11.0-borderwidth"
:description "command-line utility that can convert diagrams drawn using ascii art into proper bitmap graphics"
:min-lein-version "2.0.0"
:url "https://github.com/stathissideris/ditaa"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ public static void main(String[] args){
.create('t')
);

cmdLnOptions.addOption(
OptionBuilder.withLongOpt("border-width")
.withDescription("Border width around image (minimum 1).")
.hasArg()
.withArgName("BORDERWIDTH")
.create()
);

cmdLnOptions.addOption(
OptionBuilder.withLongOpt("background")
.withDescription("The background colour of the image. The format should be a six-digit hexadecimal number (as in HTML, FF0000 for red). Pass an eight-digit hex to define transparency. This is overridden by --transparent.")
Expand Down
33 changes: 20 additions & 13 deletions src/java/org/stathissideris/ascii2image/core/ConversionOptions.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* ditaa - Diagrams Through Ascii Art
*
*
* Copyright (C) 2004-2011 Efstathios Sideris
*
* ditaa is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
Expand All @@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with ditaa. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package org.stathissideris.ascii2image.core;

Expand All @@ -32,21 +32,21 @@
import java.util.HashMap;

/**
*
*
* @author Efstathios Sideris
*/
public class ConversionOptions {

public ProcessingOptions processingOptions =
new ProcessingOptions();
public RenderingOptions renderingOptions =
new RenderingOptions();

public void setDebug(boolean value){
processingOptions.setPrintDebugOutput(value);
renderingOptions.setRenderDebugLines(value);
}

public ConversionOptions(){}

/** Parse a color from a 6- or 8-digit hex string. For example, FF0000 is red.
Expand All @@ -65,19 +65,19 @@ public static Color parseColor(String hexString) {
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).");
}
}

public ConversionOptions(CommandLine cmdLine) throws UnsupportedEncodingException{

processingOptions.setVerbose(cmdLine.hasOption("verbose"));
renderingOptions.setDropShadows(!cmdLine.hasOption("no-shadows"));
this.setDebug(cmdLine.hasOption("debug"));
processingOptions.setOverwriteFiles(cmdLine.hasOption("overwrite"));

if(cmdLine.hasOption("scale")){
Float scale = Float.parseFloat(cmdLine.getOptionValue("scale"));
renderingOptions.setScale(scale.floatValue());
}

processingOptions.setAllCornersAreRound(cmdLine.hasOption("round-corners"));
processingOptions.setPerformSeparationOfCommonEdges(!cmdLine.hasOption("no-separation"));
renderingOptions.setAntialias(!cmdLine.hasOption("no-antialias"));
Expand All @@ -88,7 +88,7 @@ public ConversionOptions(CommandLine cmdLine) throws UnsupportedEncodingExceptio
Color background = parseColor(b);
renderingOptions.setBackgroundColor(background);
}

if(cmdLine.hasOption("transparent")) {
renderingOptions.setBackgroundColor(new Color(0,0,0,0));
}
Expand All @@ -100,12 +100,19 @@ public ConversionOptions(CommandLine cmdLine) throws UnsupportedEncodingExceptio
processingOptions.setTabSize(tabSizeValue);
}

if(cmdLine.hasOption("border-width")){
Integer borderWidth = Integer.parseInt(cmdLine.getOptionValue("border-width"));
int borderWidthValue = borderWidth.intValue();
if(borderWidthValue < 1) borderWidthValue = 1;
processingOptions.setBorderWidth(borderWidthValue);
}

String encoding = (String) cmdLine.getOptionValue("encoding");
if(encoding != null){
new String(new byte[2], encoding);
processingOptions.setCharacterEncoding(encoding);
}

if (cmdLine.hasOption("svg")){
renderingOptions.setImageType(RenderingOptions.ImageType.SVG);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* ditaa - Diagrams Through Ascii Art
*
*
* Copyright (C) 2004-2011 Efstathios Sideris
*
* ditaa is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
Expand All @@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with ditaa. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package org.stathissideris.ascii2image.core;

Expand All @@ -30,7 +30,7 @@
public class ProcessingOptions {

private HashMap<String, CustomShapeDefinition> customShapes = new HashMap<String, CustomShapeDefinition>();

private boolean beVerbose = false;
private boolean printDebugOutput = false;
private boolean overwriteFiles = false;
Expand All @@ -55,11 +55,14 @@ public class ProcessingOptions {
public static final int DEFAULT_TAB_SIZE = 8;
private int tabSize = DEFAULT_TAB_SIZE;

public static final int DEFAULT_BORDER_WIDTH = 2;
private int borderWidth = DEFAULT_BORDER_WIDTH;

private String inputFilename;
private String outputFilename;

private String characterEncoding = null;

/**
* @return
*/
Expand Down Expand Up @@ -214,6 +217,21 @@ public void setTabSize(int i) {
tabSize = i;
}

/**
* @return
*/
public int getBorderWidth() {
return borderWidth;
}

/**
* @param i
*/
public void setBorderWidth(int i) {
if (i < 1) borderWidth = 1;
else borderWidth = i;
}

public String getCharacterEncoding() {
return characterEncoding;
}
Expand All @@ -233,11 +251,11 @@ public void setCustomShapes(HashMap<String, CustomShapeDefinition> customShapes)
public void putAllInCustomShapes(HashMap<String, CustomShapeDefinition> customShapes) {
this.customShapes.putAll(customShapes);
}

public CustomShapeDefinition getFromCustomShapes(String tagName){
return customShapes.get(tagName);
}



}
Loading