Class Carto

java.lang.Object
  |
  +--Carto
All Implemented Interfaces:
java.io.Serializable

public class Carto
extends java.lang.Object
implements java.io.Serializable

The main class of the Carto program. Contains everything that is found in a .cto file.
As a general rule, variables and methods should not be in this file unless there is no other place they can go.

See Also:
Serialized Form

Field Summary
static java.lang.Thread background
          The thread in which the background job runs.
 java.io.File base
          The directory containing the .cto file
Used for finding images if things have moved.
 java.util.Vector complist
          Composites in this file.
static int COOKKILL
          Indicates that a cook job should die.
 java.lang.String created_version
          The version of Carto that created this file.
static Selection cutbuffer
           
 java.util.HashMap defaults
          Default overrides for this file.
static Unit defmapunit
          The default map unit.
static Unit defscreenunit
          The default screen unit.
(package private) static java.io.File filebase
          The base from which carto files are relative.
(package private) static java.awt.GraphicsConfiguration gconf
           
(package private) static java.awt.GraphicsEnvironment genv
           
static java.lang.String[] installfiles
           
static int kill
          A flag that tells the background job that it should die.
 Unit mapunit
          The map unit.
 EditState[] place
          The states of the editors that were open when last saved.
 PrefEditor[] prefs
          PrefEditors for this file.
static int PRINTKILL
          Indicates that a print job should die.
static Version runversion
          Represents the version running now.
 java.lang.String saved_version
          The version of Carto that last saved this file.
 Unit screenunit
          The screen unit.
 java.util.Vector sectionlist
          Cross sections in this file.
 java.util.Vector segmentlist
          Segments in this file.
private static long serialVersionUID
           
 java.util.TreeSet sizes
          Deprecated. Replaced by defaults.
 Survey survey
          Survey data for this file.
 java.util.zip.ZipEntry zipent
          If the file was int a zip, the entry it was in.
 java.util.zip.ZipFile zipfile
          If the file was in a zip the zip file it was in.
 
Constructor Summary
Carto()
          Create a new, empty carto file.
 
Method Summary
static void checkInstall()
          Make sure the instalation is complete.
static java.io.File choose(java.awt.Component parent)
          Prompt the user for a .cto file
 void clean()
          Cleans up trash.
static void cleanBackground()
          Indicate that background has died.
static void copyFile(java.lang.String name)
          Copy a file from the jar file to the base directory.
static void copyFiles(java.util.jar.JarFile source, java.lang.String[] names)
          Copies the named files from the Jar file.
 java.util.TreeSet getDefs(java.lang.Class type)
          Get the defaults of a given type.
 java.util.Vector getList(java.lang.String name)
          Gets list of eliments by type
static java.lang.String[] getSubdirList(java.util.jar.JarFile source, java.lang.String dirname)
          Gets the names of all the contents of a directory in a Jar file
 void hardReCookAll(ThreadMessage message, CartoFrame owner)
          Hard recook of all segments.
Currently this just calls reCookAll, because there is no soft recook anymore.
static void main(java.lang.String[] args)
          Start the Carto program.
 void printStats(java.io.PrintStream out)
          Print some basic statistics for the file.
static Carto read(java.io.File filename)
          Read a Carto from a file.
private  void readObject(java.io.ObjectInputStream stream)
          Reads a Carto from a stream.
 void reCookAll(ThreadMessage message, CartoFrame owner)
          Recook all segments.
Throws out the morphed version of all segments and forces them to be remorphed from scratch.
 void remove(Vertex station)
          Remove any use of station.
Used to make it safe to delete station from survey.
static boolean startBackground(java.lang.Thread action)
          Start a background job.
static void stopBackground(int killval)
          Kill the background job.
 java.lang.String used(Vertex station)
          Tells if station is used anywhere,
other than in survey.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID

filebase

static java.io.File filebase
The base from which carto files are relative. (if any)


genv

static java.awt.GraphicsEnvironment genv

gconf

static java.awt.GraphicsConfiguration gconf

cutbuffer

public static Selection cutbuffer

sizes

public java.util.TreeSet sizes
Deprecated. Replaced by defaults.

The set of sizes for this file


defaults

public java.util.HashMap defaults
Default overrides for this file. Keys are types, values are sets of FileDefaultables of that type.


survey

public Survey survey
Survey data for this file.


complist

public java.util.Vector complist
Composites in this file. This only includes top level Composites. There may be composites included in the file that are not in complist (usr defined symbols etc).


segmentlist

public java.util.Vector segmentlist
Segments in this file. ALL segments referenced from this must be in segmentlist. Does not include section and profile segments


sectionlist

public java.util.Vector sectionlist
Cross sections in this file. ALL sections referenced from this must be in sectionlist.


place

public EditState[] place
The states of the editors that were open when last saved.


prefs

public PrefEditor[] prefs
PrefEditors for this file. These contain the file specific preferences.


defscreenunit

public static Unit defscreenunit
The default screen unit. New files get their screen unit from here. Is set by a global Pref.


defmapunit

public static Unit defmapunit
The default map unit. New files get their map unit from here. Is set by a global Pref.


screenunit

public Unit screenunit
The screen unit. This is the default unit for distances on the screen. It is not really used for much.


mapunit

public Unit mapunit
The map unit. Determines what units the survey data are defined in terms off. If not set correctly, survey data will not be interpreted correctly.


runversion

public static Version runversion
Represents the version running now.


created_version

public java.lang.String created_version
The version of Carto that created this file.


saved_version

public java.lang.String saved_version
The version of Carto that last saved this file.


base

public transient java.io.File base
The directory containing the .cto file
Used for finding images if things have moved.


zipent

public transient java.util.zip.ZipEntry zipent
If the file was int a zip, the entry it was in.


zipfile

public transient java.util.zip.ZipFile zipfile
If the file was in a zip the zip file it was in.


background

public static java.lang.Thread background
The thread in which the background job runs. If null, then there is no background job. Background jobs are used for cooking and printing. Only one is allowed at a time because they are not thread safe. Background jobs must clear this pointer when the end.


kill

public static int kill
A flag that tells the background job that it should die. Background jobs should clear this flag when they die.


COOKKILL

public static int COOKKILL
Indicates that a cook job should die.


PRINTKILL

public static int PRINTKILL
Indicates that a print job should die.


installfiles

public static java.lang.String[] installfiles
Constructor Detail

Carto

public Carto()
Create a new, empty carto file.

Method Detail

choose

public static java.io.File choose(java.awt.Component parent)
Prompt the user for a .cto file


read

public static Carto read(java.io.File filename)
Read a Carto from a file. Sorts out its defaults.


getList

public java.util.Vector getList(java.lang.String name)
Gets list of eliments by type


clean

public void clean()
Cleans up trash. Deletes Segments that are referenced but not listed. Put code to fix other inconsitent states here.


used

public java.lang.String used(Vertex station)
Tells if station is used anywhere,
other than in survey. If so, returns string saying how. Otherwise returns null. Used to decide if safe to delete station from survey.


remove

public void remove(Vertex station)
Remove any use of station.
Used to make it safe to delete station from survey.


startBackground

public static boolean startBackground(java.lang.Thread action)
Start a background job. Makes sure that there is not one already.


cleanBackground

public static void cleanBackground()
Indicate that background has died. Must only be called by the background job. Must always be called by any background job before dieing


stopBackground

public static void stopBackground(int killval)
Kill the background job. Waits for the job to die.


reCookAll

public void reCookAll(ThreadMessage message,
                      CartoFrame owner)
Recook all segments.
Throws out the morphed version of all segments and forces them to be remorphed from scratch.


hardReCookAll

public void hardReCookAll(ThreadMessage message,
                          CartoFrame owner)
Hard recook of all segments.
Currently this just calls reCookAll, because there is no soft recook anymore.


getDefs

public java.util.TreeSet getDefs(java.lang.Class type)
Get the defaults of a given type. Returns the set of default overides, if any.


readObject

private void readObject(java.io.ObjectInputStream stream)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Reads a Carto from a stream. We define this method to fix up the old file to work with the current version.

java.io.IOException
java.lang.ClassNotFoundException

getSubdirList

public static java.lang.String[] getSubdirList(java.util.jar.JarFile source,
                                               java.lang.String dirname)
                                        throws java.io.IOException
Gets the names of all the contents of a directory in a Jar file

java.io.IOException

copyFiles

public static void copyFiles(java.util.jar.JarFile source,
                             java.lang.String[] names)
                      throws java.io.IOException
Copies the named files from the Jar file. Puts the results in the base directory. If any of the named files are directories copies the files they contain as well

java.io.IOException

copyFile

public static void copyFile(java.lang.String name)
Copy a file from the jar file to the base directory.


checkInstall

public static void checkInstall()
Make sure the instalation is complete. If not, complete it. Uses version.txt to determine what needs to be unpacked. If needed unpacks symbol libraries and optional files (gpl.txt + example files (if any)). If persist.sta does not exist, create it.


printStats

public void printStats(java.io.PrintStream out)
Print some basic statistics for the file.


main

public static void main(java.lang.String[] args)
Start the Carto program. Initializes error log, reads persistant state, prints about message, and shows a new CartoFrame.
CartoFrame does most top level functions, but it has the wrong name to be the main class.