01: package com.vividsolutions.jump.workbench.imagery;
02:
03: /*
04: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
05: * for visualizing and manipulating spatial features with geometry and attributes.
06: *
07: * Copyright (C) 2003 Vivid Solutions
08: *
09: * This program is free software; you can redistribute it and/or
10: * modify it under the terms of the GNU General Public License
11: * as published by the Free Software Foundation; either version 2
12: * of the License, or (at your option) any later version.
13: *
14: * This program is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: * GNU General Public License for more details.
18: *
19: * You should have received a copy of the GNU General Public License
20: * along with this program; if not, write to the Free Software
21: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22: *
23: * For more information, contact:
24: *
25: * Vivid Solutions
26: * Suite #1A
27: * 2328 Government Street
28: * Victoria BC V8T 5G5
29: * Canada
30: *
31: * (250)385-6040
32: * www.vividsolutions.com
33: */
34: import com.vividsolutions.jump.JUMPException;
35: import com.vividsolutions.jump.feature.Feature;
36: import com.vividsolutions.jump.workbench.model.Layer;
37: import com.vividsolutions.jump.workbench.ui.Viewport;
38: import com.vividsolutions.jump.workbench.ui.renderer.style.Style;
39:
40: /**
41: * A JUMP style that will paint images
42: */
43: public class ReferencedImageStyle implements Style {
44: boolean enabled = true;
45:
46: public ReferencedImageStyle() {
47: }
48:
49: private ImageryLayerDataset imageryLayerDataset = new ImageryLayerDataset();
50:
51: public void paint(Feature f, java.awt.Graphics2D g,
52: Viewport viewport) throws Exception {
53: if (imageryLayerDataset.referencedImage(f) == null) {
54: return;
55: }
56: try {
57: imageryLayerDataset.referencedImage(f)
58: .paint(f, g, viewport);
59: } catch (JUMPException e) {
60: f.setAttribute(ImageryLayerDataset.ATTR_ERROR, e
61: .getMessage());
62: viewport.getPanel().getContext().setStatusMessage(
63: "Error reading image.");
64: }
65: }
66:
67: public void initialize(Layer l) {
68: }
69:
70: public Object clone() {
71: return new ReferencedImageStyle();
72: }
73:
74: public void setEnabled(boolean enabled) {
75: this .enabled = enabled;
76: }
77:
78: public boolean isEnabled() {
79: return enabled;
80: }
81:
82: public ImageryLayerDataset getImageryLayerDataset() {
83: return imageryLayerDataset;
84: }
85: }
|