com.reades.mapthing
Class Lines

java.lang.Object
  extended by com.reades.mapthing.Generic
      extended by com.reades.mapthing.Lines
All Implemented Interfaces:
Serializable

public class Lines
extends Generic
implements Serializable

Creates lines from a MultiLine shape file in ArcGIS or (still looking for test cases) x/y pairs in a CSV file.

Issues to be tested/implemented:

See Also:
Serialized Form

Field Summary
 boolean DEBUG
           
 
Constructor Summary
Lines(BoundingBox b,  f)
          Instantiate the GeoLine object with a BoundingBox and Feature Collection object.
Lines(BoundingBox b, String r)
          Instantiate the GeoLine object with a BoundingBox and String.
 
Method Summary
 ArrayList<Coordinate[]> getCoordinates()
          Returns an ArrayList of the raw coordinates contained in the shape file.
 ArrayList<Node[]> getCoordinates(PApplet a)
          Return an ArrayList, each row of which contains an array of Nodes.
 void project(PApplet a)
          Draws all of the lines contained in a Lines object loaded from a file.
 void project(PApplet a, PGraphics p)
          Draws all of the lines contained in a Lines object loaded from a file into a PGraphics object so that you can use it as a buffer.
 void projectValues(PApplet a, float min, float max)
          Apply a color scale to the the polygons so that it is possible to represent the values in a useful way.
 void reverse()
          Reverses the order of the points in a polygon.
 void transformCoordinates(PApplet a)
          You don't normally need to call this directly, as it will be done for you when you ask for the file to be projected in the Applet.
 
Methods inherited from class com.reades.mapthing.Generic
appendNearestFeatures, getBounds, getCentroids, getFeatures, getMultipleFeaturesById, getMultipleFeaturesById, getMultipleFeaturesById, getMultipleFeaturesByPattern, getMultipleFeaturesByPattern, getMultipleFeaturesByPattern, getMultipleFeaturesByValue, getProjection, getProjection, interpolateColor, map, setColorScale, setColorScale, setColourScale, setColourScale, setGlobalSimplificationThreshold, setLabelField, setLabelField, setLocalSimplificationThreshold, setValueField, setValueField
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public boolean DEBUG
Constructor Detail

Lines

public Lines(BoundingBox b,
             String r)
Instantiate the GeoLine object with a BoundingBox and String. Depending on whether the String ends in .csv or .shp we will employ the appropriate tool to open and read the data.

Parameters:
b - the bounding box of the default view
r - a String that allows us to determine the type of resource to open

Lines

public Lines(BoundingBox b,
              f)
Instantiate the GeoLine object with a BoundingBox and Feature Collection object.

Parameters:
b - the bounding box of the default viewport
f - a reference to FeatureCollection of SimpleFeature objects
Method Detail

transformCoordinates

public void transformCoordinates(PApplet a)
You don't normally need to call this directly, as it will be done for you when you ask for the file to be projected in the Applet. However, I have left the method public to offer people the opportunity to improvise or improve on the code.

Parameters:
a - a Processing PApplet object

getCoordinates

public ArrayList<Node[]> getCoordinates(PApplet a)
Return an ArrayList, each row of which contains an array of Nodes. The idea is that each array represents a separate set of lines that can be drawn in the sketch. To some extent this is just a stub left over from a previous implementation, but it does provide us with the capacity to insert some logic in between asking for the coordinates and getting back the transformed result.

Returns:
ArrayList

getCoordinates

public ArrayList<Coordinate[]> getCoordinates()
Returns an ArrayList of the raw coordinates contained in the shape file. You don't normally need to worry about these, but they could be useful if you wanted to completely bypass the mapping process for some reason (e.g. you won't to show things in polar coordinates).

Returns:
ArrayList

project

public void project(PApplet a)
Draws all of the lines contained in a Lines object loaded from a file. The simplest way to work with this method is to set the color, fill, and stroke in your sketch and then just call this function by passing it the Applet instance (probably by saying: object.project(this).

Parameters:
a - a Processing PApplet object

projectValues

public void projectValues(PApplet a,
                          float min,
                          float max)
Apply a color scale to the the polygons so that it is possible to represent the values in a useful way.

Parameters:
a - a Processing PApplet object
min - the minimum value of the value field (I will try to make this automatic in later releases)
max - the maximum value of the value field (I will try to make this automatic in later releases)

project

public void project(PApplet a,
                    PGraphics p)

Draws all of the lines contained in a Lines object loaded from a file into a PGraphics object so that you can use it as a buffer.

Parameters:
a - a Processing PApplet object
p - a Processing PGraphics

reverse

public void reverse()

Reverses the order of the points in a polygon. Note that this will only do something if you have already called transformCoordinates or project once (since it only works on the points that have been mapped into the Processing sketch.



Processing library MapThing by Jon Reades. (C) 2013