source: trunk/src/org/expeditee/items/FrameImage.java@ 1102

Last change on this file since 1102 was 1102, checked in by davidb, 6 years ago

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

File size: 2.2 KB
Line 
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
19package org.expeditee.items;
20
21import org.expeditee.core.Image;
22import org.expeditee.gui.Frame;
23import org.expeditee.gui.FrameGraphics;
24import org.expeditee.gui.FrameIO;
25
26public class FrameImage extends FramePicture {
27 /**
28 * Creates a new Picture from the given path. The ImageObserver is optional
29 * and can be set to NULL. <br>
30 * Note: It is assumed that the file described in path has already been
31 * checked to exist.
32 *
33 * @param source
34 * The Text Item that was used to create this Picture
35 * @param path
36 * The Path of the Image to load from disk.
37 * @param observer
38 * The ImageObserver to assign when painting the Image on the
39 * screen.
40 */
41 public FrameImage(Text source, Image image) {
42 super(source, image);
43 }
44
45 @Override
46 protected Picture createPicture() {
47 return new FrameImage(_source.copy(), _image);
48 }
49
50 @Override
51 public boolean refresh() {
52 // Need to parse the first time the frame is being displayed
53 // parseSize();
54 assert (_source.getLink() != null);
55 Frame frame = FrameIO.LoadFrame(_source.getAbsoluteLink(), null, true);
56 if (frame == null)
57 return false;
58
59 frame.setBuffer(FrameGraphics.getFrameImage(frame, null, null, false, false));
60 _image = frame.getBuffer();
61
62 // TODO tidy this up, need to call parse size only when the frame has
63 // been created to begin with
64 parseSize();
65 invalidateBounds();
66 return true;
67 }
68
69 @Override
70 protected String getTagText() {
71 return "@f: ";
72 }
73}
Note: See TracBrowser for help on using the repository browser.