source: main/trunk/greenstone3/src/java/org/greenstone/applet/phind/JPhindTitle.java@ 38800

Last change on this file since 38800 was 38800, checked in by anupama, 4 months ago

Added some extra class comments to indicate the new classes added are swing ports to work with the new JAppelt JPhind (instead of the old awt Applet Phind). The port of the phind applet's classes from awt to swing are with an eye on getting the Phind applet to work with webswing which doesn't work with awt Applets only with JApplet, as Dr Bainbridge had warned.

File size: 2.5 KB
Line 
1/**********************************************************************
2 *
3 * JPhindTitle.java -- backdrops to empty ResultDisplay panels.
4 *
5 * Copyright 1997-2000 Gordon W. Paynter
6 * Copyright 2000 The New Zealand Digital Library Project
7 *
8 * A component of the Greenstone digital library software
9 * from the New Zealand Digital Library Project at the
10 * University of Waikato, New Zealand.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 *********************************************************************/
27
28
29/*********************************************************************
30
31JPhindTitle is a swing port of awt PhindTitle to be used by swing JPhind
32JApplet a.o.t Phind awt Applet.
33I'm not sure if this got exercised during testing.
34
35PhindTitle is for drawing backdrops in empty ResultDisplay panels.
36
37**********************************************************************/
38package org.greenstone.applet.phind;
39
40//import java.applet.Applet;
41//import java.awt.Canvas;
42import javax.swing.JComponent;
43import java.awt.Color;
44import java.awt.Dimension;
45import java.awt.Graphics;
46import java.awt.Image;
47
48// To convert awt Canvas to swing, need to make it a JComponent
49// https://stackoverflow.com/questions/776180/how-to-make-canvas-with-swing
50public class JPhindTitle extends JComponent {
51
52 JPhind phind;
53 static Image backgroundImage;
54 boolean displayInfo;
55
56 JPhindTitle(JPhind p) {
57 phind = p;
58 }
59
60 public void paintComponent(Graphics g) {
61 super.paintComponent(g);
62
63 Dimension canvasSize = getSize();
64
65 Color fore = phind.panel_fg;
66 Color back = phind.panel_bg;
67
68 // set the screen background
69 if (phind.showImage)
70 try {
71 g.drawImage(phind.backgroundImage,
72 0, 0, canvasSize.width, canvasSize.height, back, null);
73 } catch (Exception e) {
74 System.err.println("PhindTitle paint: " + e);
75 }
76 else {
77 g.setColor(back);
78 g.fillRect(0,0, canvasSize.width, canvasSize.height);
79 }
80 }
81}
82
83
84
85
86
87
88
Note: See TracBrowser for help on using the repository browser.