|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| CompositeTrack.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* EJTools, the Enterprise Java Tools
|
|
| 3 |
*
|
|
| 4 |
* Distributable under LGPL license.
|
|
| 5 |
* See terms of license at www.gnu.org.
|
|
| 6 |
*/
|
|
| 7 |
package org.ejtools.graph;
|
|
| 8 |
|
|
| 9 |
import java.awt.Color;
|
|
| 10 |
import java.awt.Graphics;
|
|
| 11 |
import java.awt.GridLayout;
|
|
| 12 |
import java.util.Collection;
|
|
| 13 |
import java.util.Iterator;
|
|
| 14 |
import java.util.Vector;
|
|
| 15 |
|
|
| 16 |
import javax.swing.JComponent;
|
|
| 17 |
import javax.swing.JPanel;
|
|
| 18 |
|
|
| 19 |
/**
|
|
| 20 |
* Description of the Class
|
|
| 21 |
*
|
|
| 22 |
* @author Laurent Etiemble
|
|
| 23 |
* @version $Revision: 1.8 $
|
|
| 24 |
* @todo Javadoc to complete
|
|
| 25 |
*/
|
|
| 26 |
public class CompositeTrack implements GraphElement, LabelElement |
|
| 27 |
{
|
|
| 28 |
/** Description of the Field */
|
|
| 29 |
protected JPanel component;
|
|
| 30 |
/** Description of the Field */
|
|
| 31 |
protected GridLayout layout;
|
|
| 32 |
/** Description of the Field */
|
|
| 33 |
protected Collection tracks = new Vector(); |
|
| 34 |
|
|
| 35 |
|
|
| 36 |
/** Constructor for the Track object */
|
|
| 37 | 0 |
public CompositeTrack()
|
| 38 |
{
|
|
| 39 | 0 |
this.layout = new GridLayout(1, 1, 1, 1); |
| 40 | 0 |
this.component = new JPanel(this.layout); |
| 41 |
} |
|
| 42 |
|
|
| 43 |
|
|
| 44 |
/**
|
|
| 45 |
* Adds a feature to the Track attribute of the CompositeTrack object
|
|
| 46 |
*
|
|
| 47 |
* @param t The feature to be added to the Track attribute
|
|
| 48 |
*/
|
|
| 49 | 0 |
public void addTrack(Track t) |
| 50 |
{
|
|
| 51 | 0 |
this.tracks.add(t);
|
| 52 | 0 |
this.layout.setRows(this.tracks.size()); |
| 53 | 0 |
this.component.add(t.getComponent());
|
| 54 |
} |
|
| 55 |
|
|
| 56 |
|
|
| 57 |
/** Description of the Method */
|
|
| 58 | 0 |
public void clear() |
| 59 |
{
|
|
| 60 | 0 |
synchronized (this.tracks) |
| 61 |
{
|
|
| 62 | 0 |
for (Iterator it = this.tracks.iterator(); it.hasNext(); ) |
| 63 |
{
|
|
| 64 | 0 |
((Track) it.next()).clear(); |
| 65 |
} |
|
| 66 |
} |
|
| 67 |
} |
|
| 68 |
|
|
| 69 |
|
|
| 70 |
/**
|
|
| 71 |
* @param graphics Description of the Parameter
|
|
| 72 |
* @param scaleX Description of the Parameter
|
|
| 73 |
* @param offsetX Description of the Parameter
|
|
| 74 |
* @param scaleY Description of the Parameter
|
|
| 75 |
* @param offsetY Description of the Parameter
|
|
| 76 |
*/
|
|
| 77 | 0 |
public void draw(Graphics graphics, double scaleX, double offsetX, double scaleY, double offsetY) |
| 78 |
{
|
|
| 79 | 0 |
synchronized (this.tracks) |
| 80 |
{
|
|
| 81 | 0 |
for (Iterator it = this.tracks.iterator(); it.hasNext(); ) |
| 82 |
{
|
|
| 83 | 0 |
((GraphElement) it.next()).draw(graphics, scaleX, offsetX, scaleY, offsetY); |
| 84 |
} |
|
| 85 |
} |
|
| 86 |
} |
|
| 87 |
|
|
| 88 |
|
|
| 89 |
/**
|
|
| 90 |
* @return The color value
|
|
| 91 |
*/
|
|
| 92 | 0 |
public Color getColor()
|
| 93 |
{
|
|
| 94 | 0 |
return Color.black;
|
| 95 |
} |
|
| 96 |
|
|
| 97 |
|
|
| 98 |
/**
|
|
| 99 |
* @return The component value
|
|
| 100 |
*/
|
|
| 101 | 0 |
public JComponent getComponent()
|
| 102 |
{
|
|
| 103 | 0 |
return this.component; |
| 104 |
} |
|
| 105 |
|
|
| 106 |
|
|
| 107 |
/**
|
|
| 108 |
* @return The xRange value
|
|
| 109 |
*/
|
|
| 110 | 0 |
public Range getXRange()
|
| 111 |
{
|
|
| 112 | 0 |
synchronized (this.tracks) |
| 113 |
{
|
|
| 114 | 0 |
Range result = new Range(Double.MAX_VALUE, Double.MIN_VALUE);
|
| 115 | 0 |
for (Iterator it = this.tracks.iterator(); it.hasNext(); ) |
| 116 |
{
|
|
| 117 | 0 |
result = result.compose(((GraphElement) it.next()).getXRange()); |
| 118 |
} |
|
| 119 | 0 |
return result;
|
| 120 |
} |
|
| 121 |
} |
|
| 122 |
|
|
| 123 |
|
|
| 124 |
/**
|
|
| 125 |
* @return The yRange value
|
|
| 126 |
*/
|
|
| 127 | 0 |
public Range getYRange()
|
| 128 |
{
|
|
| 129 | 0 |
synchronized (this.tracks) |
| 130 |
{
|
|
| 131 | 0 |
Range result = new Range(Double.MAX_VALUE, Double.MIN_VALUE);
|
| 132 | 0 |
for (Iterator it = this.tracks.iterator(); it.hasNext(); ) |
| 133 |
{
|
|
| 134 | 0 |
result = result.compose(((GraphElement) it.next()).getYRange()); |
| 135 |
} |
|
| 136 | 0 |
return result;
|
| 137 |
} |
|
| 138 |
} |
|
| 139 |
|
|
| 140 |
|
|
| 141 |
/**
|
|
| 142 |
* Description of the Method
|
|
| 143 |
*
|
|
| 144 |
* @param t Description of the Parameter
|
|
| 145 |
*/
|
|
| 146 | 0 |
public void removeTrack(Track t) |
| 147 |
{
|
|
| 148 | 0 |
if (this.tracks.contains(t)) |
| 149 |
{
|
|
| 150 | 0 |
this.component.remove(t.getComponent());
|
| 151 | 0 |
this.tracks.remove(t);
|
| 152 | 0 |
this.layout.setRows(this.tracks.size()); |
| 153 |
} |
|
| 154 |
} |
|
| 155 |
} |
|
| 156 |
|
|
||||||||||