Merging MK branch rev. 581 (Methods for recoloring graphs)
This commit is contained in:
parent
3f5b844101
commit
16634440b0
@ -263,7 +263,7 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (FunctionArea.this.m_PointSetContainer.size() > 0) {
|
if (FunctionArea.this.m_PointSetContainer.size() > 0) { // there is at least one graph
|
||||||
String togGTTName = (isShowGraphToolTips() ? "Deactivate":"Activate") + " graph tool tips";
|
String togGTTName = (isShowGraphToolTips() ? "Deactivate":"Activate") + " graph tool tips";
|
||||||
JMenuItem togGraphToolTips = new JMenuItem(togGTTName);
|
JMenuItem togGraphToolTips = new JMenuItem(togGTTName);
|
||||||
togGraphToolTips.addActionListener(new ActionListener() {
|
togGraphToolTips.addActionListener(new ActionListener() {
|
||||||
@ -291,17 +291,23 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
});
|
});
|
||||||
GraphMenu.add(removeGraph);
|
GraphMenu.add(removeGraph);
|
||||||
|
|
||||||
JMenuItem changecolorGraph = new JMenuItem(
|
JMenuItem changecolorGraph = new JMenuItem("Change graph color");
|
||||||
"Change color");
|
changecolorGraph.addActionListener(new ActionListener() {
|
||||||
changecolorGraph
|
public void actionPerformed(ActionEvent ee) {
|
||||||
.addActionListener(new ActionListener() {
|
changeColorGraph(FunctionArea.this.m_x,
|
||||||
public void actionPerformed(ActionEvent ee) {
|
FunctionArea.this.m_y);
|
||||||
changeColorGraph(FunctionArea.this.m_x,
|
}
|
||||||
FunctionArea.this.m_y);
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
GraphMenu.add(changecolorGraph);
|
GraphMenu.add(changecolorGraph);
|
||||||
|
|
||||||
|
JMenuItem changeAllColors = new JMenuItem("Recolor all graphs");
|
||||||
|
changeAllColors.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent ee) {
|
||||||
|
recolorAllGraphsByIndex();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GraphMenu.add(changeAllColors);
|
||||||
|
|
||||||
JMenuItem removePoint = new JMenuItem("Remove point");
|
JMenuItem removePoint = new JMenuItem("Remove point");
|
||||||
removePoint.addActionListener(new ActionListener() {
|
removePoint.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent ee) {
|
public void actionPerformed(ActionEvent ee) {
|
||||||
@ -335,6 +341,10 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
getGraphPointSet(GraphLabel).incColor();
|
getGraphPointSet(GraphLabel).incColor();
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setColorByIndex(int graphLabel, int colorIndex) {
|
||||||
|
getGraphPointSet(graphLabel).setColorByIndex(colorIndex);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -349,6 +359,21 @@ public class FunctionArea extends DArea implements Serializable {
|
|||||||
updateLegend();
|
updateLegend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-color all graphs which are nonempty by their index.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void recolorAllGraphsByIndex() {
|
||||||
|
int index=0;
|
||||||
|
for (int i=0; i<m_PointSetContainer.size(); i++) {
|
||||||
|
GraphPointSet gps = ((GraphPointSet) (this.m_PointSetContainer.get(i)));
|
||||||
|
if (gps.getPointCount()>0) {
|
||||||
|
gps.setColorByIndex(index);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
@ -102,6 +102,10 @@ public class Graph implements Serializable {
|
|||||||
m_Plotter.jump();
|
m_Plotter.jump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setColorByIndex(int j) {
|
||||||
|
((Plot)m_Plotter).setColorByIndex(m_GraphLabel, j);
|
||||||
|
}
|
||||||
|
|
||||||
// public boolean isValid() { // this was evil in RMI, use GraphWindow instead
|
// public boolean isValid() { // this was evil in RMI, use GraphWindow instead
|
||||||
// //return true;
|
// //return true;
|
||||||
// return (m_Plotter != null) && (m_Plotter.getFunctionArea() != null);
|
// return (m_Plotter != null) && (m_Plotter.getFunctionArea() != null);
|
||||||
|
@ -33,6 +33,18 @@ import eva2.tools.math.Mathematics;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GraphPointSet {
|
public class GraphPointSet {
|
||||||
|
// Color sequence of the plot graphs
|
||||||
|
public static Color[] colorSequence =
|
||||||
|
new Color[]{
|
||||||
|
Color.black, Color.red, Color.blue, Color.pink, Color.green,
|
||||||
|
Color.gray, Color.magenta, Color.cyan, Color.orange,
|
||||||
|
new Color(148, 0, 211), // dark violet,
|
||||||
|
new Color(72 , 209 , 204), // turquoise
|
||||||
|
new Color(128 ,128 ,0), // olive
|
||||||
|
new Color(34 ,139 ,34), // forest green
|
||||||
|
new Color(100 ,149 ,237 ) // cornflower
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -404,41 +416,8 @@ public class GraphPointSet {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Color indexToColor(int index) {
|
private Color indexToColor(int index) {
|
||||||
Color c = Color.black;
|
int k = index % colorSequence.length;
|
||||||
int k = index % 10;
|
return colorSequence[k];
|
||||||
switch (k) {
|
|
||||||
case 0:
|
|
||||||
c = Color.black;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
c = Color.red;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
c = Color.blue;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
c = Color.pink;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
c = Color.green;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
c = Color.gray;
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
c = Color.magenta;
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
c = Color.cyan;
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
c = Color.orange;
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
c = Color.darkGray;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -490,6 +490,14 @@ public class Plot implements PlotInterface, Serializable {
|
|||||||
setUnconnectedPoint(range[0][1], range[1][1], graphLabel);
|
setUnconnectedPoint(range[0][1], range[1][1], graphLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setColorByIndex(int graphLabel, int index) {
|
||||||
|
getFunctionArea().setColorByIndex(graphLabel, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void recolorAllGraphsByIndex() {
|
||||||
|
getFunctionArea().recolorAllGraphsByIndex();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Just for testing the Plot class.
|
// * Just for testing the Plot class.
|
||||||
// */
|
// */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user