// **********************************************************************
//
//
* This class needs the RecordSet to be called with the following
* query:
* select CITY (string), STATE (string), GRAPHIC (string, url or
* graphic name), LATITUDE (float), LONGITUDE (float) from
* LOCATION_TABLE (tablename where data is stored)
* The class is expecting the results in this order.
*/
public abstract class LocationDataRecordImpl
implements LocationDataRecord
{
/* variables that would hold current values of record set */
protected int recID;
protected String labelString;
protected LocationColorFormatter.LocColorEntry colorFormatter;
protected float latitude, longitude;
public LocationDataRecordImpl() {}
// ----------------------------------------------------------------
/** Modifier methods */
public void setRecID(int val) { recID = val;}
public void setDisplayName(String val) { labelString = val;}
public void setGraphicName(String val) { }
public void setLatitude(float val) { latitude = val; }
public void setLongitude(float val) { longitude = val; }
public void setColorFormatter(LocationColorFormatter.LocColorEntry val) { colorFormatter = val; }
// ----------------------------------------------------------------
/** Accessor methods */
public int getRecID() { return recID;}
public String getDisplayName() { return labelString;}
public String getGraphicName() { return ""; }
public float getLatitude() { return latitude; }
public float getLongitude() { return longitude; }
public LocationColorFormatter.LocColorEntry getColorFormatter() { return colorFormatter; }
// ----------------------------------------------------------------
public void setLocationColors(LocationColorFormatter colfmt, Object value)
{
if(colfmt != null && value != null)
{
setColorFormatter(colfmt.getEntry(value));
}
}
// ----------------------------------------------------------------
/**
* Description string
* @return String
*/
public String getDetails()
{ return toString();}
// ----------------------------------------------------------------
/**
* Default output string
* @return String
*/
public String toString() {
StringBuffer s = new StringBuffer();
s.append(getDisplayName());
s.append(" @ ( " + latitude + "," + longitude + ")");
return s.toString();
}
// ----------------------------------------------------------------
/**
* Get the color used for the location graphic.
*/
public Color getLocationColor(Color defcolor) { return defcolor;}
// ----------------------------------------------------------------
/**
* Get the color used for the label.
*/
public Color getLabelColor(Color defcolor) { return defcolor;}
// ----------------------------------------------------------------
/**
* Get the color used for the label.
*/
public OMGraphic getGraphic()
{
OMRaster retVal = new OMRaster();
retVal.setImageIcon(getImageIcon(null));
return retVal;
}
// ----------------------------------------------------------------
public String getImageUrl()
{
// ImageIcon icon = new ImageIcon(iconURL);
return "file:///C:/J_Projects/GIS/openmap-4.6.3/src/openmap/com/bbn/openmap/layer/location/generic/CYAN16_D.png";
}
// ----------------------------------------------------------------
public Image getImage()
{
Image img = java.awt.Toolkit.getDefaultToolkit().getImage(getImageUrl());
BufferedImage bi = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
// Graphics2D g = bi.createGraphics();
// g.drawImage(img);
bi.createGraphics().drawImage(img, 0, 0, null);
return bi;
}
// ----------------------------------------------------------------
public ImageIcon getImageIcon(LocationColorFormatter colfmt)
{
// ImageIcon icon = new ImageIcon(iconURL);
return new ImageIcon(getImage());
}
// ----------------------------------------------------------------
public URL getIcon(String iconurl)
{
try
{
return PropUtils.getResourceOrFileOrURL(null, iconurl);
}
catch (java.net.MalformedURLException mue)
{ throw new com.bbn.openmap.util.HandleError(mue); }
}
}