add xShift function for GraphicCollection

This commit is contained in:
wyq 2021-08-12 16:42:04 +08:00
parent 11e2dd5bbb
commit 85a3e6cdac
2 changed files with 38 additions and 2 deletions

View File

@ -5,6 +5,9 @@
*/
package org.meteoinfo.chart.plot3d;
import org.meteoinfo.common.Extent3D;
import org.meteoinfo.common.PointD;
import org.meteoinfo.geometry.graphic.Graphic;
import org.meteoinfo.geometry.graphic.GraphicCollection;
import java.util.List;
@ -178,4 +181,20 @@ public class GraphicCollection3D extends GraphicCollection{
public void setUsingLight(boolean value) {
this.usingLight = value;
}
/**
* X coordinate shift
* @param xs X shift value
*/
public GraphicCollection xShift(double xs) {
for (Graphic g : this.graphics) {
for (PointD p : g.getShape().getPoints()) {
p.X += xs;
}
g.setExtent(((Extent3D) g.getExtent()).shift(xs, 0, 0));
}
this._extent.shift(xs, 0);
return this;
}
}

View File

@ -13,6 +13,7 @@
*/
package org.meteoinfo.geometry.graphic;
import org.meteoinfo.common.Extent3D;
import org.meteoinfo.geometry.legend.*;
import org.meteoinfo.common.Extent;
import org.meteoinfo.common.MIMath;
@ -33,8 +34,8 @@ import java.util.NoSuchElementException;
public class GraphicCollection extends Graphic implements Iterator {
// <editor-fold desc="Variables">
private List<Graphic> graphics = new ArrayList<>();
private Extent _extent = new Extent();
protected List<Graphic> graphics = new ArrayList<>();
protected Extent _extent = new Extent();
protected boolean singleLegend = true;
private int index;
private LabelSet labelSet;
@ -682,5 +683,21 @@ public class GraphicCollection extends Graphic implements Iterator {
return cgraphics;
}
/**
* X coordinate shift
* @param xs X shift value
*/
public GraphicCollection xShift(double xs) {
for (Graphic g : this.graphics) {
for (PointD p : g.getShape().getPoints()) {
p.X += xs;
}
g.setExtent(g.getExtent().shift(xs, 0));
}
this._extent.shift(xs, 0);
return this;
}
// </editor-fold>
}