1 | /**
|
---|
2 | * FrameImage.java
|
---|
3 | * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
|
---|
4 | *
|
---|
5 | * This program is free software: you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | */
|
---|
18 |
|
---|
19 | package org.expeditee.items;
|
---|
20 |
|
---|
21 | import java.awt.Image;
|
---|
22 | import java.awt.image.ImageObserver;
|
---|
23 |
|
---|
24 | import org.expeditee.gui.Frame;
|
---|
25 | import org.expeditee.gui.FrameGraphics;
|
---|
26 | import org.expeditee.gui.FrameIO;
|
---|
27 |
|
---|
28 | public class FrameImage extends FramePicture {
|
---|
29 | /**
|
---|
30 | * Creates a new Picture from the given path. The ImageObserver is optional
|
---|
31 | * and can be set to NULL. <br>
|
---|
32 | * Note: It is assumed that the file described in path has already been
|
---|
33 | * checked to exist.
|
---|
34 | *
|
---|
35 | * @param source
|
---|
36 | * The Text Item that was used to create this Picture
|
---|
37 | * @param path
|
---|
38 | * The Path of the Image to load from disk.
|
---|
39 | * @param observer
|
---|
40 | * The ImageObserver to assign when painting the Image on the
|
---|
41 | * screen.
|
---|
42 | */
|
---|
43 | public FrameImage(Text source, ImageObserver observer, Image image) {
|
---|
44 | super(source, observer, image);
|
---|
45 | }
|
---|
46 |
|
---|
47 | @Override
|
---|
48 | protected Picture createPicture() {
|
---|
49 | return new FrameImage(_source.copy(), _imageObserver, _image);
|
---|
50 | }
|
---|
51 |
|
---|
52 | @Override
|
---|
53 | public boolean refresh() {
|
---|
54 | // Need to parse the first time the frame is being displayed
|
---|
55 | // parseSize();
|
---|
56 | assert (_source.getLink() != null);
|
---|
57 | Frame frame = FrameIO.LoadFrame(_source.getAbsoluteLink(), null, true);
|
---|
58 | if (frame == null)
|
---|
59 | return false;
|
---|
60 |
|
---|
61 | frame.setBuffer(null);
|
---|
62 | FrameGraphics.UpdateBuffer(frame, false, false);
|
---|
63 | _image = frame.getBuffer();
|
---|
64 |
|
---|
65 | // TODO tidy this up, need to call parse size only when the frame has
|
---|
66 | // been created to begin with
|
---|
67 | parseSize();
|
---|
68 | updatePolygon();
|
---|
69 | return true;
|
---|
70 | }
|
---|
71 |
|
---|
72 | @Override
|
---|
73 | protected String getTagText() {
|
---|
74 | return "@f: ";
|
---|
75 | }
|
---|
76 | }
|
---|