1 27 package org.objectweb.clif.console.lib.gui; 28 29 import java.awt.Color ; 30 import java.awt.geom.Point2D ; 31 import java.util.Vector ; 32 33 36 public class InjectorsGraph { 37 public String name; 39 public Color color; 41 public Vector [] points; 43 private boolean isLimited; 45 public int maxElements; 47 private int size; 49 50 55 public InjectorsGraph(int size, boolean isLimited) { 56 this.isLimited = isLimited; 57 this.size = size; 58 maxElements = 5; 60 61 points = new Vector [size]; 63 for (int i = 0; i < size; i++) { 64 points[i] = new Vector (); 65 } 66 } 67 68 69 74 public void addPoint(Point2D.Double point, int type) 75 { 76 points[type].addElement(point); 77 if (isLimited && points[type].size() > maxElements) 78 { 79 points[type].removeElementAt(0); 80 } 81 } 82 83 84 87 public void clearAllPoints() { 88 for (int i = 0; i < points.length; i++) { 91 points[i].removeAllElements(); 92 } 94 } 95 96 97 102 public void setMaxElements(int nbPoints) 103 { 104 if (nbPoints < maxElements) 105 { 106 for (int i = 0; i < size; i++) 107 { 108 while (points[i].size() > nbPoints) 109 { 110 points[i].removeElementAt(0); 111 } 112 } 113 } 114 maxElements = nbPoints; 115 } 116 117 public int getMaxElements() { 118 return maxElements; 119 } 120 121 } 122 | Popular Tags |