1 /* -------------------------------------------------------------------
2 GeoVISTA Center (Penn State, Dept. of Geography)
3 Java source file for the class SpaceFillMatrixElement
4 Copyright (c), 2002, GeoVISTA Center
5 All Rights Reserved.
6 Original Author: Frank Hardisty
7 $Author: hardisty $
8 $Id: SpaceFillMatrixElement.java,v 1.4 2003/07/18 14:06:45 hardisty Exp $
9 $Date: 2003/07/18 14:06:45 $
10 Reference: Document no:
11 ___ ___
12 ------------------------------------------------------------------- *
13
14 */
15
16
17 package edu.psu.geovista.app.spacefill;
18
19
20 import javax.swing.*;
21 import java.awt.*;
22 import java.awt.event.*;
23 import java.awt.image.*;
24 import java.awt.geom.*;
25 import java.awt.font.*;
26 import java.util.*;
27
28 import edu.psu.geovista.app.matrix.*;
29 import edu.psu.geovista.symbolization.*;
30
31 public class SpaceFillMatrixElement extends SpaceFillCanvas
32 implements MatrixElement {
33
34 //the following are required for returning to matrix
35 private int[] elementPosition;
36 private double[] xAxisExtents;
37 private double[] yAxisExtents;
38 private Object[] dataSet;
39 private Color selectionColor;
40
41 public SpaceFillMatrixElement() {
42 super();
43 super.setUseDrawingShapes(false);
44 this.setBorder(BorderFactory.createLineBorder(Color.darkGray,1));
45 }
46
47 public void setDataObject(Object[] data) {
48 this.dataSet = data;
49 super.setData(data);
50 }
51
52 public void setElementPosition(int[] dataIndices){
53 this.elementPosition = (int[])dataIndices.clone();
54 super.setCurrOrderColumn(this.elementPosition[0]);//order = x
55 super.setCurrColorColumn(this.elementPosition[1]);//color = y
56
57
58 }
59
60 public int[] getElementPosition(){
61 return this.elementPosition;
62 }
63
64 //For axes of scatter plot.
65 //a noop for this class
66 public void setAxisOn (boolean axisOn){
67 }
68
69
70
71
72 //Set min and max for axes. xAxisExtents[0] = min, [1] = max.
73 public void setXAxisExtents (double[] xAxisExtents){
74
75 }
76
77 public void setYAxisExtents (double[] yAxisExtents){ }
78
79 public double[] getXAxisExtents () {
80 return this.xAxisExtents;
81 }
82
83 public double[] getYAxisExtents () {
84 return this.yAxisExtents;
85 }
86
87 public String getShortDiscription () {
88 return "SFP";
89 }
90 //public void setBivarColorClasser (BivariateColorSymbolClassification bivarColorClasser) {
91 //this.bivarColorClasser = bivarColorClasser;
92 //this.sendColorsToLayers(this.dataColorX.length);
93 //}
94
95 public void setSelectionColor (Color c){
96 this.selectionColor = c;
97 super.setColorSelection(c);
98 }
99
100 public Color getSelectionColor (){
101 return this.selectionColor;
102 }
103
104 public void setMultipleSelectionColors (Color[] c){
105 }
106
107 public void setColorArrayForObs (Color[] c){
108 }
109 /***
110 * This method only paints the current contents of the drawingBuff.
111 * @param g
112 */
113 public void paintComponent (Graphics g) {
114 super.paintComponent(g);
115
116 if (this.elementPosition == null) {
117 return;
118 }
119
120 if (this.elementPosition[0] == this.elementPosition[1]) {
121 Graphics2D g2 = (Graphics2D)g;
122 Color half = new Color(255,255,255,150);
123 g2.setColor(half);
124 Font font = new Font("Serif",Font.PLAIN,24);
125 g2.setFont(font);
126 FontRenderContext frc = g2.getFontRenderContext();
127
128 String[] varNames = (String[])this.dataSet[0];
129 String varName = varNames[this.elementPosition[0]-1];//-1 to skip string array
130
131 int midX = 10;
132 int midY = this.getHeight()/2;
133
134 Rectangle2D textBounds = g2.getFont().getStringBounds(varName,frc);
135 Rectangle rect = textBounds.getBounds();
136 rect.setSize(rect.width,(int)(rect.height * 1.5));
137 rect.setLocation(midX,midY - (int)(rect.getHeight()/1.5));
138 //Rectangle rect = new Rectangle();
139 rect.setLocation(0,0);
140 rect.setSize(this.getWidth(),this.getHeight());
141 g2.fill(rect);
142 //g2.fillRect(0,0,this.getWidth(),this.getHeight());
143 g2.setColor(Color.black);
144
145
146
147 //g2.drawString(varName,midX,midY);
148 }
149 }
150
151 }
This page was automatically generated by Maven