Skip to content

Commit

Permalink
Initial import.
Browse files Browse the repository at this point in the history
  • Loading branch information
adufilie committed May 15, 2011
0 parents commit 91958dd
Show file tree
Hide file tree
Showing 900 changed files with 210,287 additions and 0 deletions.
7 changes: 7 additions & 0 deletions GeometryStreamConverter/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
31 changes: 31 additions & 0 deletions GeometryStreamConverter/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GeometryStreamConverter</name>
<comment></comment>
<projects>
<project>GeometryStreamConverter</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
12 changes: 12 additions & 0 deletions GeometryStreamConverter/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#Mon Oct 04 05:45:56 EDT 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Mon Oct 04 05:45:56 EDT 2010
classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER\:\:org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType\:\:jdk1.6.0_18/owners=jst.java\:5.0
eclipse.preferences.version=1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Thu Oct 29 23:42:00 EDT 2009
eclipse.preferences.version=1
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="GeometryStreamConverter">
<wb-resource deploy-path="/" source-path="/src"/>
</wb-module>
</project-modules>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="jst.java"/>
<fixed facet="jst.utility"/>
<installed facet="jst.utility" version="1.0"/>
<installed facet="jst.java" version="5.0"/>
</faceted-project>
18 changes: 18 additions & 0 deletions GeometryStreamConverter/GeometryStreamConverter.jardesc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
<jardesc>
<jar path="GeometryStreamConverter/GeometryStreamConverter.jar"/>
<options buildIfNeeded="true" compress="true" descriptionLocation="/GeometryStreamConverter/GeometryStreamConverter.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/>
<manifest generateManifest="false" manifestLocation="/GeometryStreamConverter/src/META-INF/MANIFEST.MF" manifestVersion="1.0" reuseManifest="true" saveManifest="true" usesManifest="true">
<sealing sealJar="true">
<packagesToSeal/>
<packagesToUnSeal/>
</sealing>
</manifest>
<selectedElements exportClassFiles="false" exportJavaFiles="false" exportOutputFolder="true">
<folder path="/GeometryStreamConverter/src/META-INF"/>
<javaElement handleIdentifier="=GeometryStreamConverter/src&lt;org.oicweave.utils"/>
<javaElement handleIdentifier="=GeometryStreamConverter/src&lt;org.oicweave.geometrystream"/>
</selectedElements>
</jardesc>
674 changes: 674 additions & 0 deletions GeometryStreamConverter/LICENSE.txt

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions GeometryStreamConverter/src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Sealed: true

105 changes: 105 additions & 0 deletions GeometryStreamConverter/src/org/oicweave/geometrystream/Bounds2D.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
Weave (Web-based Analysis and Visualization Environment)
Copyright (C) 2008-2011 University of Massachusetts Lowell
This file is a part of Weave.
Weave is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License, Version 3,
as published by the Free Software Foundation.
Weave is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Weave. If not, see <http://www.gnu.org/licenses/>.
*/

package org.oicweave.geometrystream;

/**
* The code in this class assumes xMin < xMax and yMin < yMax
*
* @author adufilie
*
*/
public class Bounds2D
{
public Bounds2D()
{
reset();
}
public Bounds2D(double xMin, double yMin, double xMax, double yMax)
{
this.xMin = xMin;
this.yMin = yMin;
this.xMax = xMax;
this.yMax = yMax;
}
public boolean overlaps(Bounds2D other)
{
return this.xMin <= other.xMax && other.xMin <= this.xMax
&& this.yMin <= other.yMax && other.yMin <= this.yMax;
}
public double getImportance()
{
// use area if it is > 0
double width = xMax - xMin;
double height = yMax - yMin;
double area = width * height;
if (area > 0)
return area;
// if area is 0, return length squared instead (vertical or horizontal line)
double length = width + height; // either width or height is 0
if (length > 0)
return length * length;
// if length is 0, return REQUIRED (point)
return VertexChainLink.IMPORTANCE_REQUIRED;
}
public double getCenterX()
{
return (xMax + xMin) / 2;
}
public double getCenterY()
{
return (yMax + yMin) / 2;
}
public void includePoint(double x, double y)
{
xMin = (Double.isNaN(xMin)) ? x : Math.min(xMin, x);
xMax = (Double.isNaN(xMax)) ? x : Math.max(xMax, x);
yMin = (Double.isNaN(yMin)) ? y : Math.min(yMin, y);
yMax = (Double.isNaN(yMax)) ? y : Math.max(yMax, y);
}
public void includeBounds(Bounds2D other)
{
includePoint(other.xMin, other.yMin);
includePoint(other.xMax, other.yMax);
}
public void reset()
{
xMin = Double.NaN;
yMin = Double.NaN;
xMax = Double.NaN;
yMax = Double.NaN;
}
public boolean isUndefined()
{
return Double.isNaN(xMin)
|| Double.isNaN(yMin)
|| Double.isNaN(xMax)
|| Double.isNaN(yMax);
}

public String toString()
{
return String.format("(%s, %s, %s, %s)",xMin,yMin,xMax,yMax);
}

public double xMin;
public double yMin;
public double xMax;
public double yMax;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/*
Weave (Web-based Analysis and Visualization Environment)
Copyright (C) 2008-2011 University of Massachusetts Lowell
This file is a part of Weave.
Weave is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License, Version 3,
as published by the Free Software Foundation.
Weave is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Weave. If not, see <http://www.gnu.org/licenses/>.
*/

package org.oicweave.geometrystream;

import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Stack;

import org.oicweave.geometrystream.StreamObject;

/**
* @author adufilie
*/
public class CombinedPoint implements StreamObject
{
private CombinedPoint()
{
}

private LinkedList<VertexIdentifier> vertexIdentifiers = new LinkedList<VertexIdentifier>();
Bounds2D queryBounds = new Bounds2D();
public double x;
public double y;
public double importance = VertexChainLink.IMPORTANCE_UNKNOWN;

public CombinedPoint initialize(double x, double y)
{
clear();
this.x = x;
this.y = y;
return this;
}

public void clear()
{
for (VertexIdentifier vertexIdentifier : vertexIdentifiers)
VertexIdentifier.saveUnusedInstance(vertexIdentifier);
vertexIdentifiers.clear();
queryBounds.reset();
}

public void addPoint(int shapeID, Bounds2D pointQueryBounds, VertexChainLink point)
{
if (this.x != point.x || this.y != point.y)
throw new RuntimeException("CombinedPoint.addPoint(): coordinates of new point do not match");
vertexIdentifiers.add(VertexIdentifier.getUnusedInstance(shapeID, point.vertexID));
queryBounds.includeBounds(pointQueryBounds);
}

public Bounds2D getQueryBounds()
{
return queryBounds;
}

public void updateMinimumImportance(double minimumImportance)
{
importance = Math.max(importance, minimumImportance);
}

public int getStreamSize()
{
// (int shapeID, int vertexID) * vertexIdentifiers.size(), double x, double y, float importance
return (Integer.SIZE/8 * 2) * vertexIdentifiers.size() + (Double.SIZE/8) * 2 + (Float.SIZE/8);
}

public void writeStream(DataOutputStream pointStream) throws IOException
{
// binary format: <int shapeID1, int vertexID1, int shapeID2, int vertexID2, ..., int shapeID(n-1), int vertexID(n-1), int shapeID(n), int negativeVertexID(n), double x, double y, float importance>
// loop through vertex identifiers
Iterator<VertexIdentifier> iter = vertexIdentifiers.iterator();
VertexIdentifier vertexIdentifier;
while (iter.hasNext())
{
vertexIdentifier = iter.next();
// write shapeID
pointStream.writeInt(vertexIdentifier.shapeID);
// write vertexID (negative if it is the last one)
if (!iter.hasNext())
pointStream.writeInt(-1 - vertexIdentifier.vertexID);
else
pointStream.writeInt(vertexIdentifier.vertexID);
}
// write x,y coordinates
pointStream.writeDouble(x);
pointStream.writeDouble(y);
// write importance value
pointStream.writeFloat((float)importance);
}

private static final long serialVersionUID = -7090731893590156775L;

public double getImportance()
{
return importance;
}

public double getX()
{
return x;
}

public double getY()
{
return y;
}

/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(x);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(y);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}

/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj)
{
CombinedPoint other = (CombinedPoint) obj;
return x == other.x && y == other.y;
}

private static Stack<CombinedPoint> unusedInstances = new Stack<CombinedPoint>();
public static void saveUnusedInstance(CombinedPoint combinedPoint)
{
combinedPoint.clear();
unusedInstances.push(combinedPoint);
}
public static CombinedPoint getUnusedInstance(double x, double y)
{
CombinedPoint result;
if (unusedInstances.size() == 0)
result = new CombinedPoint();
else
result = unusedInstances.pop();
result.initialize(x, y);
return result;
}
}
Loading

0 comments on commit 91958dd

Please sign in to comment.