public final class SceneExporter extends Object
ArrayList<WidgetPolygonalCoordinates> list = null ;
try {
list = SceneExporter.createImageMap(scene,
imageFile, imageType, zoomType,
visibleAreaOnly, selectedOnly, quality,
horizontal, vertical, margin);
} catch (Exception e) {
//Something bad happened
return;
}
html.append("<img src=\"scene.jpg\" usemap=\"#WidgetMap\"/>\n");
String[] mapSections = new String[list.size()];
int count = 0;
for (WidgetPolygonalCoordinates wc: list) {
Widget widget = wc.getWidget();
String name = "no name";
if (widget instanceof SimpleWidget) {
name = ((SimpleWidget) widget).getUserObject().getLabel();
} else if (widget instanceof SimpleConnectionWidget) {
name = ((SimpleConnectionWidget) widget).getUserObject().getLabel();
}
String coordinateString = pointsToString(wc.getPolygon());
mapSections[count++] = "<area shape=\"polygon\" coords=\"" + coordinateString + "\" href=\"#" + name + "\">";
html.append("<li><a name=\"").append(name).append("\">");
html.append(name).append("</a><br>\n");
html.append(getRandomText(100)).append("</li>\n");
}
html.append("\n<map name=\"WidgetMap\">\n");
for (String s : mapSections) {
html.append(s).append("\n");
}
html.append("</map>");
Modifier and Type | Class and Description |
---|---|
static class |
SceneExporter.ImageType
This enumeration holds the possible image formats that the SceneExporter
can export to.
|
static class |
SceneExporter.ZoomType
This enumeration holds the zooming capabilities that the SceneExporter
can export according to.
|
Modifier and Type | Method and Description |
---|---|
static BufferedImage |
createImage(Scene scene,
File file,
SceneExporter.ImageType imageType,
SceneExporter.ZoomType zoomType,
boolean visibleAreaOnly,
boolean selectedOnly,
int quality,
int width,
int height)
Takes the Scene and writes an image file according to the constraints
defined by the caller.
|
static ArrayList<WidgetPolygonalCoordinates> |
createImageMap(Scene scene,
File file,
SceneExporter.ImageType imageType,
SceneExporter.ZoomType zoomType,
boolean visibleAreaOnly,
boolean selectedOnly,
int quality,
int width,
int height,
int margin)
Designed to create an HTML image map from an exported image.
|
public static ArrayList<WidgetPolygonalCoordinates> createImageMap(Scene scene, File file, SceneExporter.ImageType imageType, SceneExporter.ZoomType zoomType, boolean visibleAreaOnly, boolean selectedOnly, int quality, int width, int height, int margin) throws IOException
scene
- The Scene to be exported as an image. The Widgets will be collected
from this scene and polygons create that wrap each widget. The coordinates
of each polygon are stored in an instance of WidgetPolygonalCoordinates.file
- The file used to store the exported image. If null, the method
immediately returns null.imageType
- The image type to be exported for the image map.zoomType
- Defines the strategy
by which to set the exporting scale factor. Note that certain parameters are
nullified by the choice of ZoomType. For instance, if ZoomType.CUSTOM_SIZE is
not chosen, then the width and height parameters are not used.visibleAreaOnly
- Eliminates all zoom features. If true, the exported
image will be a created from the visible area of the scene.selectedOnly
- Create an image including only the objects selected on
the scene. Note that this feature requires that the scene is an instance of
an ObjectScene since it is the implementation that allows for object selection.quality
- And integer value between 0-100. This is for JPG images only. Parameter is not used if
an image type other than jpg is selected.width
- Directly sets the horizontal dimension of the exported image.
This is only used when the zoomType is ZoomType.CUSTOM_SIZEheight
- Directly sets the vertical dimension of the exported image.
This is only used when the zoomType is ZoomType.CUSTOM_SIZE.margin
- The size of the clickable margin around each connection. This is
meant for defining the sensitivity of the links around the connection objects.
Note that the area around the node objects is not affected by this margin.IOException
- If for some reason the file cannot be written,
an IOExeption will be thrown.public static BufferedImage createImage(Scene scene, File file, SceneExporter.ImageType imageType, SceneExporter.ZoomType zoomType, boolean visibleAreaOnly, boolean selectedOnly, int quality, int width, int height) throws IOException
scene
- The Scene to be exported as an image.file
- The file used to store the exported image. If null, then it is
assumed that the raw image is to be returned only and not written to a file.imageType
- The image type to be exported for the image map.zoomType
- Defines the strategy
by which to set the exporting scale factor. Note that certain parameters are
nullified by the choice of ZoomType. For instance, if ZoomType.CUSTOM_SIZE is
not chosen, then the width and height parameters are not used.visibleAreaOnly
- Eliminates all zoom features. If true, the exported
image will be a created from the visible area of the scene.selectedOnly
- Create an image including only the objects selected on
the scene. Note that this feature requires that the scene is an instance of
an ObjectScene since it is the implementation that allows for object selection.quality
- And integer value between 0-100. This is for JPG images only. Parameter is not used if
an image type other than jpg is selected.width
- Directly sets the horizontal dimension of the exported image.
This is only used when the zoomType is ZoomType.CUSTOM_SIZEheight
- Directly sets the vertical dimension of the exported image.
This is only used when the zoomType is ZoomType.CUSTOM_SIZE.IOException
- If for some reason the file cannot be written,
an IOExeption will be thrown.