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
65 changes: 65 additions & 0 deletions examples/sourcemeter_mapping_example.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<mapping version="2.0">
<resources>
<constant id="cellar_character" value="planks"/>
<constant id="cellar_external_character" value="wood"/>
</resources>
<linking source="package" target="ground"/>
<linking source="class" target="garden">
<binding from="CBO" to="flower-ratio">
<conversions>
<conversion type="normalize"/>
</conversions>
</binding>
</linking>
<linking source="method" target="floor">
<binding from="LLOC" to="height"/>
<binding from="LOC" to="BuiltMetric1"/>
<binding from="NII" to="width"/>
<binding from="NOS" to="BuiltMetric2"/>
<binding from="NOI" to="length"/>
<binding from="NII" to="BuiltMetric3"/>
<binding from="McCC" to="character">
<conversions>
<conversion type="quantization">
<parameter name="level0" value="glass"/>
<parameter name="level1" value="sand"/>
<parameter name="level2" value="planks"/>
<parameter name="level3" value="stone"/>
<parameter name="level4" value="obsidian"/>
</conversion>
</conversions>
</binding>
<binding from="McCC" to="external_character">
<conversions>
<conversion type="quantization">
<parameter name="level0" value="metal"/>
<parameter name="level1" value="sandstone"/>
<parameter name="level2" value="wood"/>
<parameter name="level3" value="cobblestone"/>
<parameter name="level4" value="obsidian"/>
</conversion>
</conversions>
</binding>
<binding from="NUMPAR" to="torches">
<conversions>
<conversion type="quantization">
<parameter name="level0" value="1"/>
<parameter name="level1" value="2"/>
<parameter name="level2" value="3"/>
</conversion>
</conversions>
</binding>
</linking>
<linking source="attribute" target="cellar">
<binding from="WarningP0" to="torches">
<conversions>
<conversion type="quantization">
<parameter name="level0" value="1"/>
<parameter name="level1" value="2"/>
</conversion>
</conversions>
</binding>
<binding from="${cellar_character}" to="character"/>
<binding from="${cellar_external_character}" to="external_character"/>
</linking>
</mapping>
44 changes: 8 additions & 36 deletions sources/codemetropolis-toolchain-commons/.classpath
Original file line number Diff line number Diff line change
@@ -1,38 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-lang3/3.4/commons-lang3-3.4.jar"/>
<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/2.6.1/gson-2.6.1.jar"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
</classpath>
37 changes: 16 additions & 21 deletions sources/codemetropolis-toolchain-commons/.project
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>codemetropolis-toolchain-commons</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
<name>codemetropolis-toolchain-commons</name>
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
<projects/>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public enum Type {
GARDEN,
FLOOR,
CELLAR,
CONTAINER;
CONTAINER,


}

private String id;
Expand All @@ -28,6 +30,7 @@ public enum Type {
private List<Buildable> children;
private Buildable parent;
private String cdfNames;
private int BuiltMetric1, BuiltMetric2, BuiltMetric3;

public Buildable(String id, String name, Type type) {
this(id, name, type, new Point(), new Point());
Expand Down Expand Up @@ -165,7 +168,7 @@ public void addAttribute(String name, String value) {
name,
value
);
attributes.add(a);
attributes.add(a);
}

public void addAttributes(Attribute... attributes) {
Expand Down Expand Up @@ -310,6 +313,30 @@ public void setSizeZ(int z) {
size.setZ(z);
}

public int getBuiltMetric1() {
return BuiltMetric1;
}

public void setBuiltMetric1(int builtMetric1) {
BuiltMetric1 = builtMetric1;
}

public int getBuiltMetric2() {
return BuiltMetric2;
}

public void setBuiltMetric2(int builtMetric2) {
BuiltMetric2 = builtMetric2;
}

public int getBuiltMetric3() {
return BuiltMetric3;
}

public void setBuiltMetric3(int builtMetric3) {
BuiltMetric3 = builtMetric3;
}

public Attribute[] getAttributes() {
return attributes.toArray(new Attribute[attributes.size()]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,22 @@ public void loadFromFile(String path) throws CmxmlReaderException {
}

Point size;



if(eElement.getElementsByTagName("size").item(0) != null && eElement.getElementsByTagName("size").item(0).getParentNode() == nNode) {
size = new Point(
Integer.parseInt(((Element)eElement.getElementsByTagName("size").item(0)).getAttribute("x")),
Integer.parseInt(((Element)eElement.getElementsByTagName("size").item(0)).getAttribute("y")),
Integer.parseInt(((Element)eElement.getElementsByTagName("size").item(0)).getAttribute("z"))
);
} else {
Integer.parseInt(((Element) eElement.getElementsByTagName("size").item(0)).getAttribute("x")),
Integer.parseInt(((Element) eElement.getElementsByTagName("size").item(0)).getAttribute("y")),
Integer.parseInt(((Element) eElement.getElementsByTagName("size").item(0)).getAttribute("z"))
);



}
else {
size = new Point();

}

Buildable b = new Buildable(
Expand All @@ -163,14 +171,16 @@ public void loadFromFile(String path) throws CmxmlReaderException {
position,
size
);



NodeList attributeNodes = eElement.getElementsByTagName("attributes").item(0).getChildNodes();

for(int i = 1; attributeNodes.item(i) != null; i += 2) {
b.addAttribute(
((Element)attributeNodes.item(i)).getAttribute("name"),
((Element)attributeNodes.item(i)).getAttribute("value")
);

}

if(!nNode.getParentNode().getNodeName().equals("buildables")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ public static void load(String filePath) {
}

public static void logInfo(String message) {
if(logger == null) return;
logger.log(Level.INFO, message);
}

public static void logWarning(String message, Exception exception) {
if(logger == null) return;
logger.log(Level.WARNING, message, exception);
}

public static void logError(String message, Exception exception) {
if(logger == null) return;
logger.log(Level.SEVERE, message, exception);
}

Expand Down
34 changes: 10 additions & 24 deletions sources/codemetropolis-toolchain-converter/.classpath
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/codemetropolis-toolchain-commons"/>
<classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-lang3/3.4/commons-lang3-3.4.jar"/>
<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/2.6.1/gson-2.6.1.jar"/>
<classpathentry kind="var" path="M2_REPO/args4j/args4j/2.32/args4j-2.32.jar"/>
<classpathentry kind="var" path="M2_REPO/sed/graphlib/1.0/graphlib-1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
</classpath>
39 changes: 18 additions & 21 deletions sources/codemetropolis-toolchain-converter/.project
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>codemetropolis-toolchain-converter</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
<name>codemetropolis-toolchain-converter</name>
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
<projects>
<project>codemetropolis-toolchain-commons</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package codemetropolis.toolchain.converter;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -14,7 +15,7 @@ public class ConverterExecutorArgs extends ExecutorArgs {
private Map<String, String> params;

public ConverterExecutorArgs(ConverterType type, String source, String outputFile) {
this(type, source, outputFile, null);
this(type, source, outputFile, new HashMap<String, String>());
}

public ConverterExecutorArgs(ConverterType type, String source, String outputFile, Map<String, String> params) {
Expand All @@ -38,7 +39,7 @@ public String getOutputFile(){
}

public Map<String, String> getParams() {
return new HashMap<>(params);
return Collections.unmodifiableMap(params);
}

public String getParameter(String key) {
Expand Down
Loading