|
From: <de...@us...> - 2014-10-21 21:29:05
|
Revision: 8885
http://sourceforge.net/p/fudaa/svn/8885
Author: deniger
Date: 2014-10-21 21:28:53 +0000 (Tue, 21 Oct 2014)
Log Message:
-----------
maj couleur par defaut ?\195?\160 similaire
Modified Paths:
--------------
trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/editor/GrapheUpdateAction.java
trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/editor/profil/Hydraulique1dProfilLongPane.java
Added Paths:
-----------
trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/graphe/MascaretXYAreaRendererProfilLong.java
Removed Paths:
-------------
trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/graphe/GrapheUpdateAction.java
Modified: trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/editor/GrapheUpdateAction.java
===================================================================
--- trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/editor/GrapheUpdateAction.java 2014-10-21 15:32:20 UTC (rev 8884)
+++ trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/editor/GrapheUpdateAction.java 2014-10-21 21:28:53 UTC (rev 8885)
@@ -40,7 +40,6 @@
@Override
public void valueChanged(ListSelectionEvent e) {
- System.out.println("changement toto!!");
if(isAuto){
//-- do the automatic update --//
pane.visualiser(true,true);
Modified: trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/editor/profil/Hydraulique1dProfilLongPane.java
===================================================================
--- trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/editor/profil/Hydraulique1dProfilLongPane.java 2014-10-21 15:32:20 UTC (rev 8884)
+++ trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/editor/profil/Hydraulique1dProfilLongPane.java 2014-10-21 21:28:53 UTC (rev 8885)
@@ -293,7 +293,6 @@
profilsList.add(modelProfilList.get(indices[i]));
double z = calculeCoteZProfil(lsBief_.getSelectedIndex(), indices[i], 0);
- System.out.println("z de "+modelProfilList.get(indices[i]).nom()+" = "+ z);
}
getDataset().setBiefProfilModels(profilsList.toArray(new Hydraulique1dProfilModel[profilsList.size()]));
Deleted: trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/graphe/GrapheUpdateAction.java
===================================================================
--- trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/graphe/GrapheUpdateAction.java 2014-10-21 15:32:20 UTC (rev 8884)
+++ trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/graphe/GrapheUpdateAction.java 2014-10-21 21:28:53 UTC (rev 8885)
@@ -1,54 +0,0 @@
-package org.fudaa.fudaa.hydraulique1d.editor;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-/**
- * Action to update automatically the results when user perform a change.
- * @author Adrien
- *
- */
-public class GrapheUpdateAction implements ActionListener,ListSelectionListener{
-
-
- public boolean isAuto = true;
- private Hydraulique1dGraphesResultatsEditor pane;
-
- public GrapheUpdateAction(Hydraulique1dGraphesResultatsEditor p) {
- pane = p;
- pane.getPnHydro().getLstBiefCasierLiaison_().addListSelectionListener(this);
- pane.getPnHydro().getLstPasTpsSection_().addListSelectionListener(this);
- pane.getPnHydro().getLstVar().addListSelectionListener(this);
- pane.getPnHydro().getCheckboxMajAuto().addActionListener(this);
-
- }
-
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if(e.getSource() == pane.getPnHydro().getCheckboxMajAuto())
- isAuto = pane.getPnHydro().getCheckboxMajAuto().isSelected();
- else if(isAuto){
- //-- do the automatic update --//
- pane.visualiser(true,true);
-
- }
- }
-
-
- @Override
- public void valueChanged(ListSelectionEvent e) {
- System.out.println("changement toto!!");
- if(isAuto){
- //-- do the automatic update --//
- pane.visualiser(true,true);
-
- }
-
- }
-
-
-
-}
Added: trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/graphe/MascaretXYAreaRendererProfilLong.java
===================================================================
--- trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/graphe/MascaretXYAreaRendererProfilLong.java (rev 0)
+++ trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/graphe/MascaretXYAreaRendererProfilLong.java 2014-10-21 21:28:53 UTC (rev 8885)
@@ -0,0 +1,210 @@
+package org.fudaa.fudaa.hydraulique1d.graphe;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Paint;
+import java.awt.Polygon;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+import java.util.List;
+import org.jfree.chart.axis.ValueAxis;
+import org.jfree.chart.plot.CrosshairState;
+import org.jfree.chart.plot.PlotRenderingInfo;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.chart.renderer.xy.XYAreaRenderer2;
+import org.jfree.chart.renderer.xy.XYItemRendererState;
+import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
+import org.jfree.data.xy.XYDataset;
+/**
+ * Renderer pour remplir la zone du profil long
+ * @author Adrien Hadoux
+ *
+ */
+public class MascaretXYAreaRendererProfilLong extends XYAreaRenderer2{
+
+
+ public static class AreaPoint {
+ public double x;
+ public AreaPoint(double x, double y) {
+ super();
+ this.x = x;
+ this.y = y;
+ }
+ public double y;
+ }
+
+ XYLineAndShapeRenderer defaultRenderer;
+ boolean isNiveauEau = true;
+
+ boolean traceProfil = true;
+
+ private List<Integer> itemLineToDraw;
+ private boolean drawProfileLine=true;
+ final static int CURVE_SERIE = 0;
+ final static int End_CURVE_SERIE = 0;
+
+ public MascaretXYAreaRendererProfilLong(XYLineAndShapeRenderer defaultRenderer) {
+ this.defaultRenderer = defaultRenderer;
+ setPaint(new Color(132,166,188));
+ //setStroke(new BasicStroke(4));
+ }
+
+
+ private boolean mustDrawPolygone(double x1, double y1,XYDataset dataset, int item) {
+ double valNiveauEau = ((Hydraulique1dGrapheProfilLongDataset)dataset).getNiveauBas(CURVE_SERIE, item);
+ return isNiveauEau && y1 >= valNiveauEau;
+ }
+
+ /**
+ * Build the polygon corresponding to the shape between the curve and the level f water.
+ * @param domainAxis
+ * @param rangeAxis
+ * @param dataset
+ * @return
+ */
+ public List<Shape> buildShapeProfilLong(ValueAxis domainAxis, ValueAxis rangeAxis,XYDataset dataset, XYPlot plot, Rectangle2D dataArea) {
+ List<AreaPoint> listcoordonnees = new ArrayList<AreaPoint>();
+ List<AreaPoint> listniveauEau = new ArrayList<AreaPoint>();
+ itemLineToDraw = new ArrayList<Integer>();
+ List<Shape>listShape = new ArrayList<Shape>();
+ boolean first = true;
+ boolean last = false;
+ AreaPoint firstA=null, firstB=null, lastA = null, lastB = null;
+ //-- step 1 - determine all the point under the level --//
+ for(int item=0; item< dataset.getItemCount(CURVE_SERIE);item++){
+ double x = dataset.getXValue(CURVE_SERIE, item);
+ double y = dataset.getYValue(CURVE_SERIE, item);
+ double valNiveauEau = ((Hydraulique1dGrapheProfilLongDataset)dataset).getNiveauBas(CURVE_SERIE, item);
+ if(y>=valNiveauEau) {
+ AreaPoint p = new AreaPoint(x,y);
+ itemLineToDraw.add(item);
+ //-- on ajoute a la liste des coordonn\xE9es le point p mais aussi le point niveau d'eau --//
+ Line2D.Double shape = new Line2D.Double((int)domainAxis.valueToJava2D(p.x, dataArea, plot.getDomainAxisEdge())
+ ,(int)rangeAxis.valueToJava2D(p.y, dataArea, plot.getRangeAxisEdge()),
+ (int)domainAxis.valueToJava2D(p.x, dataArea, plot.getDomainAxisEdge()),
+ (int)rangeAxis.valueToJava2D(((Hydraulique1dGrapheProfilLongDataset)dataset).getNiveauBas(0, item), dataArea, plot.getRangeAxisEdge()));
+ listShape.add(shape);
+
+
+ listcoordonnees.add(p);
+ listniveauEau.add(new AreaPoint(x,valNiveauEau));
+
+ }
+ }
+
+
+ //-- step 4 - construct poly --//
+ Polygon poly = new Polygon();
+ for(AreaPoint p: listcoordonnees) {
+ poly.addPoint(
+ (int)domainAxis.valueToJava2D(p.x, dataArea, plot.getDomainAxisEdge()),
+ (int)rangeAxis.valueToJava2D(p.y, dataArea, plot.getRangeAxisEdge()));
+ }
+ //-- ensuite on termine par la liste des points d'eau dans l'ordre inverse pour avoir l'enveloppe convexe--//
+ for(int i=listniveauEau.size()-1;i>=0;i--) {
+ AreaPoint p = listniveauEau.get(i);
+ poly.addPoint(
+ (int)domainAxis.valueToJava2D(p.x, dataArea, plot.getDomainAxisEdge()),
+ (int)rangeAxis.valueToJava2D(p.y, dataArea, plot.getRangeAxisEdge()));
+ }
+
+
+
+ listShape.add(0,poly);
+ return listShape;
+
+ }
+
+ public void drawItem(Graphics2D g2,
+ XYItemRendererState state,
+ Rectangle2D dataArea,
+ PlotRenderingInfo info,
+ XYPlot plot,
+ ValueAxis domainAxis,
+ ValueAxis rangeAxis,
+ XYDataset dataset,
+ int series,
+ int item,
+ CrosshairState crosshairState,
+ int pass) {
+
+ if (!getItemVisible(series, item)) {
+ return;
+ }
+ // get the data point...
+ double x1 = dataset.getXValue(series, item);
+ double y1 = dataset.getYValue(series, item);
+ if (Double.isNaN(y1)) {
+ y1 = 0.0;
+ }
+
+ List<Shape> hotspot = null;
+
+
+ if( series == CURVE_SERIE && mustDrawPolygone(x1,y1,dataset, item)) {
+ hotspot = buildShapeProfilLong(domainAxis, rangeAxis, dataset,plot,dataArea);
+
+ }
+
+
+ Paint paint = getItemPaint(series, item);
+ Stroke stroke = getItemStroke(series, item);
+ g2.setPaint(paint);
+ g2.setStroke(stroke);
+
+
+ if( series == CURVE_SERIE && mustDrawPolygone(x1,y1,dataset, item)) {
+ if(hotspot.size() >0)
+ g2.fill(hotspot.get(0));
+ if(drawProfileLine) {
+ Color previous = g2.getColor();
+ Stroke prevStroke = g2.getStroke();
+
+ Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{9}, 0);
+ g2.setStroke(dashed);
+ g2.setColor(Color.BLACK);
+ for(int i=1;i<hotspot.size();i++) {
+ g2.draw(hotspot.get(i));
+ g2.drawString("P"+(i-1), (int)((Line2D.Double)hotspot.get(i)).x1, (int)(((Line2D.Double)hotspot.get(i)).y1*1.3));
+ }
+ g2.setColor(previous);
+ g2.setStroke(prevStroke);
+ }
+ //-- warning: must draw he prevous line curve again to draw onto the polygon shape --//
+ if(itemLineToDraw != null)
+ for(Integer itemLine:itemLineToDraw)
+ defaultRenderer.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, itemLine, crosshairState, pass);
+ }else {
+ //-- render line default renderer --//
+ defaultRenderer.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState, pass);
+ }
+
+ }
+
+
+
+
+ public boolean isNiveauEau() {
+ return isNiveauEau;
+ }
+
+ public void setNiveauEau(boolean isNiveauEau) {
+ this.isNiveauEau = isNiveauEau;
+ }
+
+
+ public boolean isDrawProfileLine() {
+ return drawProfileLine;
+ }
+
+
+ public void setDrawProfileLine(boolean drawProfileLine) {
+ this.drawProfileLine = drawProfileLine;
+ }
+
+
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|