*/
protected String readGraphics(LinkOMGraphicList graphics, Projection proj,
OMGridGenerator generator)
throws IOException, EOFException {
OMGraphic graphic;
long startTime = System.currentTimeMillis();
String header = null;
int graphicType;
// This is important, it's checked by the LinkLayer to see if
// it needs to generate the LinkOMGraphicList to see if the
// contents need to be generated.
graphics.setNeedToRegenerate(proj == null);
// doing nothing with the version number.
float ver = link.dis.readFloat();
if (ver != version) {
if (ver == .1) {// Big difference....
throw new IOException("LinkGraphicList: Versions do not match! DANGER!");
} else {
Debug.message("link", "LinkGraphicList: Versions do not match.");
}
}
if (properties != null) {
properties.clear();
}
properties = LinkProperties.read(link.dis, properties);
Debug.message("link", "LinkGraphicList: reading graphics:");
LinkProperties propertiesBuffer = new LinkProperties(properties);
while (true) {
graphic = null;
// Just consume the header, don't create a useless
// string object.
header = link.readDelimiter(false);
if (header == Link.END_TOTAL || header == Link.END_SECTION) {
long endTime = System.currentTimeMillis();
Debug.message("link", "LinkGraphicList: received "
+ graphics.size() + " graphics in "
+ (float) (endTime - startTime) / 1000.0f + " seconds");
return header;
}
graphicType = link.dis.readByte();
switch (graphicType) {
case GRAPHICTYPE_LINE:
graphic = LinkLine.read(link.dis, propertiesBuffer);
break;
case GRAPHICTYPE_POLY:
graphic = LinkPoly.read(link.dis, propertiesBuffer);
break;
case GRAPHICTYPE_RECTANGLE:
graphic = LinkRectangle.read(link.dis, propertiesBuffer);
break;
case GRAPHICTYPE_POINT:
graphic = LinkPoint.read(link.dis, propertiesBuffer);
break;
case GRAPHICTYPE_CIRCLE:
graphic = LinkCircle.read(link.dis, propertiesBuffer);
break;
case GRAPHICTYPE_ELLIPSE:
graphic = LinkEllipse.read(link.dis, propertiesBuffer);
break;
case GRAPHICTYPE_RASTER:
graphic = LinkRaster.read(link.dis, propertiesBuffer);
break;
case GRAPHICTYPE_BITMAP:
graphic = LinkBitmap.read(link.dis, propertiesBuffer);
break;
case GRAPHICTYPE_TEXT:
graphic = LinkText.read(link.dis, propertiesBuffer);
break;
case GRAPHICTYPE_GRID:
graphic = LinkGrid.read(link.dis, propertiesBuffer);
break;
default:
throw new IOException("LinkGraphicList: received unknown graphic type.");
}
if (graphic != null) {
if (graphic instanceof OMGrid) {
((OMGrid) graphic).setGenerator(generator);
}
if (proj != null) {
graphic.generate(proj);
}
graphics.add(graphic);
}
}
}