Changeset 187
- Timestamp:
- 09/08/11 19:13:44 (13 years ago)
- Location:
- ether_megapoli/trunk/service/implementation/com/ether
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ether_megapoli/trunk/service/implementation/com/ether/BouchonHelper.java
r186 r187 259 259 for( int i = 0; i < size; i++ ) 260 260 { 261 values[i] = (double) i * Math.random() ;261 values[i] = (double) i * Math.random() * delta; 262 262 cal.set( Calendar.MINUTE, (int) ( 2 + i + ( Math.random() * 8 ) ) ); 263 263 dates[i] = cal.getTime(); -
ether_megapoli/trunk/service/implementation/com/ether/EtherPlotContentServiceImpl.java
r186 r187 85 85 final List<Pair> pIdPIdListForSecondAxis = listPairOfPIdPIdForTwoAxes.getSecondValue(); 86 86 87 88 /** *********** FIRST Y-AXIS ************ **/ 89 final List<SimpleLine> lines = createLines( pIdPIdListForFirstAxis, megapoliPlot.getBeginDate(), megapoliPlot.getEndDate() ); 87 final List<SimpleLine> lines = createLines( pIdPIdListForFirstAxis, megapoliPlot.getBeginDate(), megapoliPlot.getEndDate(), 1 ); 88 final List<SimpleLine> linesForSecondAxis = createLines( pIdPIdListForSecondAxis, megapoliPlot.getBeginDate(), megapoliPlot.getEndDate(), 10 ); 90 89 final SimpleLine firstLine = lines.get( 0 ); 91 90 91 /** *********** RANGES ************ **/ 92 92 final SoTRange xnRange = firstLine.getXRange(); 93 93 final SoTRange yRange = firstLine.getYRange(); 94 94 for( final SimpleLine line : lines ) 95 { 95 96 yRange.add( line.getYRange() ); 97 xnRange.add( line.getXRange() ); 98 } 99 100 for( final SimpleLine line : linesForSecondAxis ) 101 xnRange.add( line.getXRange() ); 96 102 97 103 // TODO : automatiser le nb d'intervalles en fonction des valeurs de y 98 final Integer intervalsNumber = 10; 99 final SoTRange ynRange = Graph.computeRange( yRange, intervalsNumber ); 104 final SoTRange ynRange = Graph.computeRange( yRange, _intervalsNumber ); 100 105 101 106 // Origin point 102 107 final SoTPoint originPoint = new SoTPoint( ynRange.getStart(), xnRange.getStart() ); 103 108 104 // Create the time axis, set its range in user units and its origin. 109 110 /** ************ X-AXIS ********** **/ 105 111 // Time axis is the same for the two y-axis 106 112 final TimeAxis xbot = new TimeAxis( "X-Axis", TimeAxis.AUTO ); … … 108 114 xbot.setLocationU( originPoint ); 109 115 xbot.setLabelFont( _axisFont ); 110 // xbot.setMinorLabelInterval( 1 ); 116 xbot.setLabelHeightP( _heightAxisFont ); 117 xbot.setMajorLabelFormat( "yyyy-MM-dd HH:mm:ss" ); 111 118 112 119 // Create the vertical axis, set its range in user units and its origin. Create the axis title. 113 final PlainAxis yleft = new PlainAxis( "Y-Axis" ); 114 yleft.setRangeU( ynRange ); 115 yleft.setLocationU( originPoint ); 116 yleft.setLabelFont( _axisFont ); 117 final String yLabel = firstLine.getYMetaData().getName() + " (" + firstLine.getYMetaData().getUnits() + ")"; 118 final SGLabel ytitle = new SGLabel( "Y-Axis Title", yLabel, new Point2D.Double( 0.0, 0.0 ) ); 119 ytitle.setFont( _axisFont ); 120 ytitle.setHeightP( _heightAxisFont ); 121 yleft.setTitle( ytitle ); 120 final PlainAxis yleft = createYAxis( firstLine, ynRange, originPoint, null ); 122 121 123 122 /** ************ GRAPH ********** **/ … … 133 132 134 133 SimpleLine firstLineForSecondAxis = null; 135 List<SimpleLine> linesForSecondAxis = new ArrayList<SimpleLine>(); 134 136 135 LinearTransform ytForSecondAxis = null; 137 136 if( !pIdPIdListForSecondAxis.isEmpty() ) 138 137 { 139 linesForSecondAxis = createLines( pIdPIdListForSecondAxis, megapoliPlot.getBeginDate(), megapoliPlot.getEndDate() );140 138 firstLineForSecondAxis = linesForSecondAxis.get( 0 ); 141 139 … … 144 142 yRangeForSecondAxis.add( line.getYRange() ); 145 143 146 final SoTRange ynRangeForSecondAxis = Graph.computeRange( yRangeForSecondAxis, intervalsNumber );144 final SoTRange ynRangeForSecondAxis = Graph.computeRange( yRangeForSecondAxis, _intervalsNumber ); 147 145 final SoTPoint endPointForSecondAxis = new SoTPoint( ynRangeForSecondAxis.getStart(), xnRange.getEnd() ); 148 146 149 final PlainAxis yleftForSecondAxis = new PlainAxis( "YY-Axis" ); 150 yleftForSecondAxis.setRangeU( yRangeForSecondAxis ); 151 yleftForSecondAxis.setLocationU( endPointForSecondAxis ); 152 yleftForSecondAxis.setLabelFont( _axisFont ); 153 yleftForSecondAxis.setLabelPosition( Axis.POSITIVE_SIDE ); 154 final String yLabelForSecondAxis = firstLineForSecondAxis.getYMetaData().getName() + " (" + firstLineForSecondAxis.getYMetaData().getUnits() + ")"; 155 final SGLabel ytitleForSecondAxis = new SGLabel( "Y-Axis Title", yLabelForSecondAxis, new Point2D.Double( 0.0, 0.0 ) ); 156 ytitleForSecondAxis.setFont( _axisFont ); 157 ytitleForSecondAxis.setHeightP( _heightAxisFont ); 158 yleftForSecondAxis.setTitle( ytitleForSecondAxis ); 147 final PlainAxis yleftForSecondAxis = createYAxis( firstLineForSecondAxis, ynRangeForSecondAxis, endPointForSecondAxis, Axis.POSITIVE_SIDE ); 159 148 160 149 ytForSecondAxis = new LinearTransform( new Range2D( ystart, yend ), ynRangeForSecondAxis ); 161 graph.setYTransform( ytForSecondAxis ); 150 if( ytForSecondAxis.getRangeU().end > yt.getRangeU().end ) 151 graph.setYTransform( ytForSecondAxis ); 162 152 graph.addYAxis( yleftForSecondAxis ); 163 153 } … … 167 157 final LineAttribute lineAttribute = createRandomLineAttrbute( megapoliPlot.getAxeType() ); 168 158 graph.setData( firstLine, lineAttribute ); 169 170 // if( !pIdPIdListForSecondAxis.isEmpty() )171 // {172 // final LineAttribute attrForSecondAxis = createRandomLineAttrbute( megapoliPlot.getAxeType() );173 // graph.setData( firstLineForSecondAxis, attrForSecondAxis );174 // }175 159 176 160 /** *********** LEGEND ********* **/ … … 185 169 } 186 170 187 /** ********************************** **/188 171 /** *********** OTHER LAYERS ********* **/ 189 /** ********************************** **/ 190 for( final SimpleLine line : lines.subList( 1, lines.size() ) ) 172 addOtherLinesForOneAxis( megapoliPlot.getAxeType(), mainPane, xsize, ysize, lines, xt, yt, lkey, 1 ); 173 174 if( !pIdPIdListForSecondAxis.isEmpty() ) 175 addOtherLinesForOneAxis( megapoliPlot.getAxeType(), mainPane, xsize, ysize, linesForSecondAxis, xt, ytForSecondAxis, lkey, 0 ); 176 177 return mainPane; 178 } 179 180 /** 181 * This method adds layers corresponding to the other lines to display 182 * 183 * @param axeType 184 * @param mainPane 185 * @param xsize 186 * @param ysize 187 * @param lines 188 * @param xt 189 * @param yt 190 * @param lkey 191 * @param indexLineToBegin 192 */ 193 private void addOtherLinesForOneAxis( @NotNull final String axeType, @NotNull final JPane mainPane, final double xsize, final double ysize, @NotNull final List<SimpleLine> lines, @NotNull final LinearTransform xt, @NotNull final LinearTransform yt, @NotNull final LineKey lkey, @NotNull final Integer indexLineToBegin ) 194 { 195 for( final SimpleLine line : lines.subList( indexLineToBegin, lines.size() ) ) 191 196 { 192 197 final Layer otherLayer = new Layer( "Other Layer", new Dimension2D( xsize, ysize ) ); 193 198 mainPane.add( otherLayer ); 194 final CartesianGraph otherGraph = new CartesianGraph( " SecondGraph", xt, yt );199 final CartesianGraph otherGraph = new CartesianGraph( "Other Graph", xt, yt ); 195 200 otherLayer.setGraph( otherGraph ); 196 201 197 final LineAttribute otherLineAttribute = createRandomLineAttrbute( megapoliPlot.getAxeType());202 final LineAttribute otherLineAttribute = createRandomLineAttrbute( axeType ); 198 203 otherGraph.setData( line, otherLineAttribute ); 199 204 lkey.addLineGraph( (LineCartesianRenderer) otherGraph.getRenderer(), line.getKeyTitle() ); 200 205 } 201 202 /** *********** SECOND Y-AXIS (optional) ************ **/ 203 if( !pIdPIdListForSecondAxis.isEmpty() ) 204 { 205 // final Layer layerForSecondAxis = new Layer( "First Layer", new Dimension2D( xsize, ysize ) ); 206 // mainPane.add( layerForSecondAxis ); 207 // 208 // final List<SimpleLine> linesForSecondAxis = createLines( pIdPIdListForSecondAxis, megapoliPlot.getBeginDate(), megapoliPlot.getEndDate() ); 209 // final SimpleLine firstLineForSecondAxis = linesForSecondAxis.get( 0 ); 210 211 // final SoTRange yRangeForSecondAxis = firstLineForSecondAxis.getYRange(); 212 // for( final SimpleLine line : linesForSecondAxis ) 213 // yRangeForSecondAxis.add( line.getYRange() ); 214 // 215 // final SoTRange ynRangeForSecondAxis = Graph.computeRange( yRangeForSecondAxis, intervalsNumber ); 216 // final SoTPoint endPointForSecondAxis = new SoTPoint( ynRangeForSecondAxis.getStart(), xnRange.getEnd() ); 217 // 218 // final PlainAxis yleftForSecondAxis = new PlainAxis( "YY-Axis" ); 219 // yleftForSecondAxis.setRangeU( yRangeForSecondAxis ); 220 // yleftForSecondAxis.setLocationU( endPointForSecondAxis ); 221 // yleftForSecondAxis.setLabelFont( _axisFont ); 222 // yleftForSecondAxis.setLabelPosition( Axis.POSITIVE_SIDE ); 223 // final String yLabelForSecondAxis = firstLineForSecondAxis.getYMetaData().getName() + " (" + firstLineForSecondAxis.getYMetaData().getUnits() + ")"; 224 // final SGLabel ytitleForSecondAxis = new SGLabel( "Y-Axis Title", yLabelForSecondAxis, new Point2D.Double( 0.0, 0.0 ) ); 225 // ytitleForSecondAxis.setFont( _axisFont ); 226 // ytitleForSecondAxis.setHeightP( _heightAxisFont ); 227 // yleftForSecondAxis.setTitle( ytitleForSecondAxis ); 228 229 /** ************ GRAPH ********** **/ 230 // final CartesianGraph graphForSecondAxis = new CartesianGraph( "First Graph" ); 231 // final LinearTransform ytForSecondAxis = new LinearTransform( new Range2D( ystart, yend ), ynRangeForSecondAxis ); 232 // graphForSecondAxis.setYTransform( ytForSecondAxis ); 233 // graphForSecondAxis.addYAxis( yleftForSecondAxis ); 234 // layerForSecondAxis.setGraph( graphForSecondAxis ); 235 236 237 for( final SimpleLine line : linesForSecondAxis.subList( 0, linesForSecondAxis.size() ) ) 238 { 239 final Layer otherLayerForSecondAxis = new Layer( "Other Layer 2", new Dimension2D( xsize, ysize ) ); 240 mainPane.add( otherLayerForSecondAxis ); 241 final CartesianGraph otherGraphForSecondAxis = new CartesianGraph( "Second Graph 2", xt, ytForSecondAxis ); 242 otherLayerForSecondAxis.setGraph( otherGraphForSecondAxis ); 243 244 final LineAttribute otherLineAttribute = createRandomLineAttrbute( megapoliPlot.getAxeType() ); 245 otherGraphForSecondAxis.setData( line, otherLineAttribute ); 246 lkey.addLineGraph( (LineCartesianRenderer) otherGraphForSecondAxis.getRenderer(), line.getKeyTitle() ); 247 } 248 } 249 250 return mainPane; 251 } 206 } 207 208 @NotNull 209 private PlainAxis createYAxis( final SimpleLine line, final SoTRange ynRange, final SoTPoint originPoint, @Nullable final Integer labelPosition ) 210 { 211 final PlainAxis yleft = new PlainAxis( "Y-Axis" ); 212 yleft.setRangeU( ynRange ); 213 yleft.setLocationU( originPoint ); 214 yleft.setLabelFont( _axisFont ); 215 if( null != labelPosition ) 216 yleft.setLabelPosition( labelPosition ); 217 218 final String yLabel = line.getYMetaData().getName() + " (" + line.getYMetaData().getUnits() + ")"; 219 final SGLabel ytitle = new SGLabel( "Y-Axis Title", yLabel, new Point2D.Double( 0.0, 0.0 ) ); 220 ytitle.setFont( _axisFont ); 221 ytitle.setHeightP( _heightAxisFont ); 222 yleft.setTitle( ytitle ); 223 return yleft; 224 } 225 252 226 253 227 /** … … 311 285 */ 312 286 @NotNull 313 private List<SimpleLine> createLines( @NotNull final List<Pair> pIdPIdList, @Nullable final Date beginDate, @Nullable final Date endDate )287 private List<SimpleLine> createLines( @NotNull final List<Pair> pIdPIdList, @Nullable final Date beginDate, @Nullable final Date endDate, final Integer delta ) 314 288 throws ServiceException 315 289 { … … 333 307 334 308 // final Data valuesLists = _etherService.getListsByPlateformByParameterByPeriodForTimeSerie( plateformId, parameterId, beginDate, endDate ); 335 final Data valuesLists = BouchonHelper.createValuesForTimeSerie( 50, 5);309 final Data valuesLists = BouchonHelper.createValuesForTimeSerie( 50, delta ); 336 310 337 311 final double[] dataArray = (double[]) valuesLists.getFirstArray(); … … 889 863 protected static final int ERROR_FONT_SIZE = 10; 890 864 891 protected static final Font _axisFont = new Font( "Helvetica", Font.PLAIN, 12);892 protected static final double _heightAxisFont = 0. 2;865 protected static final Font _axisFont = new Font( "Helvetica", Font.PLAIN, 6 ); 866 protected static final double _heightAxisFont = 0.14; 893 867 protected static final double _markHeight = 0.1; 868 // Number of intervals on a Y-Axis 869 protected Integer _intervalsNumber = 10; 894 870 895 871 private EtherService _etherService;
Note: See TracChangeset
for help on using the changeset viewer.