mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
support LaTeX in 3D axes
This commit is contained in:
parent
ac5e401d22
commit
935ed680c9
@ -61,6 +61,7 @@ public class Axis implements Cloneable {
|
|||||||
protected boolean inverse;
|
protected boolean inverse;
|
||||||
protected List<Double> tickLocations;
|
protected List<Double> tickLocations;
|
||||||
protected List<ChartText> tickLabels;
|
protected List<ChartText> tickLabels;
|
||||||
|
protected List<ChartText> fixTickLabels;
|
||||||
protected boolean autoTick;
|
protected boolean autoTick;
|
||||||
protected boolean minorTickVisible;
|
protected boolean minorTickVisible;
|
||||||
protected int minorTickNum;
|
protected int minorTickNum;
|
||||||
@ -864,6 +865,7 @@ public class Axis implements Cloneable {
|
|||||||
this.tickLocations.add(v.doubleValue());
|
this.tickLocations.add(v.doubleValue());
|
||||||
this.tickLabels.add(new ChartText(String.valueOf(v), this.tickLabelFont, this.tickColor));
|
this.tickLabels.add(new ChartText(String.valueOf(v), this.tickLabelFont, this.tickColor));
|
||||||
}
|
}
|
||||||
|
this.fixTickLabels = new ArrayList<>(tickLabels);
|
||||||
this.autoTick = false;
|
this.autoTick = false;
|
||||||
if (this.tickLocations.size() > 1) {
|
if (this.tickLocations.size() > 1) {
|
||||||
this.tickDeltaValue = this.tickLocations.get(1) - this.tickLocations.get(0);
|
this.tickDeltaValue = this.tickLocations.get(1) - this.tickLocations.get(0);
|
||||||
@ -885,6 +887,7 @@ public class Axis implements Cloneable {
|
|||||||
tick = DataConvert.removeTailingZeros(tick);
|
tick = DataConvert.removeTailingZeros(tick);
|
||||||
this.tickLabels.add(new ChartText(tick, this.tickLabelFont, this.tickColor));
|
this.tickLabels.add(new ChartText(tick, this.tickLabelFont, this.tickColor));
|
||||||
}
|
}
|
||||||
|
this.fixTickLabels = new ArrayList<>(tickLabels);
|
||||||
this.autoTick = false;
|
this.autoTick = false;
|
||||||
if (this.tickLocations.size() > 1) {
|
if (this.tickLocations.size() > 1) {
|
||||||
this.tickDeltaValue = this.tickLocations.get(1) - this.tickLocations.get(0);
|
this.tickDeltaValue = this.tickLocations.get(1) - this.tickLocations.get(0);
|
||||||
@ -924,6 +927,7 @@ public class Axis implements Cloneable {
|
|||||||
for (String v : value) {
|
for (String v : value) {
|
||||||
this.tickLabels.add(new ChartText(v, this.tickLabelFont, this.tickColor));
|
this.tickLabels.add(new ChartText(v, this.tickLabelFont, this.tickColor));
|
||||||
}
|
}
|
||||||
|
this.fixTickLabels = new ArrayList<>(tickLabels);
|
||||||
this.autoTick = false;
|
this.autoTick = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -946,6 +950,7 @@ public class Axis implements Cloneable {
|
|||||||
for (Number v : value) {
|
for (Number v : value) {
|
||||||
this.tickLabels.add(new ChartText(v.toString(), this.tickLabelFont, this.tickColor));
|
this.tickLabels.add(new ChartText(v.toString(), this.tickLabelFont, this.tickColor));
|
||||||
}
|
}
|
||||||
|
this.fixTickLabels = new ArrayList<>(this.tickLabels);
|
||||||
this.autoTick = false;
|
this.autoTick = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1236,15 +1241,15 @@ public class Axis implements Cloneable {
|
|||||||
} else {
|
} else {
|
||||||
ChartText ct;
|
ChartText ct;
|
||||||
for (int i = 0; i < this.tickLocations.size(); i++) {
|
for (int i = 0; i < this.tickLocations.size(); i++) {
|
||||||
if (i >= this.tickLabels.size()) {
|
if (i >= this.fixTickLabels.size()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
double v = this.tickLocations.get(i);
|
double v = this.tickLocations.get(i);
|
||||||
if (v >= this.minValue && v <= this.maxValue) {
|
if (v >= this.minValue && v <= this.maxValue) {
|
||||||
ct = tickLabels.get(i);
|
ct = fixTickLabels.get(i);
|
||||||
ct.setFont(this.tickLabelFont);
|
ct.setFont(this.tickLabelFont);
|
||||||
ct.setColor(this.tickColor);
|
ct.setColor(this.tickColor);
|
||||||
tls.add(this.tickLabels.get(i));
|
tls.add(ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,8 @@ import org.meteoinfo.chart.shape.TextureShape;
|
|||||||
import org.meteoinfo.common.*;
|
import org.meteoinfo.common.*;
|
||||||
import org.meteoinfo.common.colors.ColorMap;
|
import org.meteoinfo.common.colors.ColorMap;
|
||||||
import org.meteoinfo.data.Dataset;
|
import org.meteoinfo.data.Dataset;
|
||||||
|
import org.meteoinfo.geo.drawing.Draw;
|
||||||
|
import org.meteoinfo.geo.drawing.StringType;
|
||||||
import org.meteoinfo.geometry.colors.BoundaryNorm;
|
import org.meteoinfo.geometry.colors.BoundaryNorm;
|
||||||
import org.meteoinfo.geometry.colors.Normalize;
|
import org.meteoinfo.geometry.colors.Normalize;
|
||||||
import org.meteoinfo.geometry.graphic.Graphic;
|
import org.meteoinfo.geometry.graphic.Graphic;
|
||||||
@ -36,6 +38,9 @@ import org.meteoinfo.geometry.shape.Shape;
|
|||||||
import org.meteoinfo.math.meteo.MeteoMath;
|
import org.meteoinfo.math.meteo.MeteoMath;
|
||||||
import org.meteoinfo.projection.ProjectionInfo;
|
import org.meteoinfo.projection.ProjectionInfo;
|
||||||
import org.meteoinfo.projection.ProjectionUtil;
|
import org.meteoinfo.projection.ProjectionUtil;
|
||||||
|
import org.scilab.forge.jlatexmath.TeXConstants;
|
||||||
|
import org.scilab.forge.jlatexmath.TeXFormula;
|
||||||
|
import org.scilab.forge.jlatexmath.TeXIcon;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@ -1946,69 +1951,71 @@ public class GLPlot extends Plot {
|
|||||||
float tickLen = this.xAxis.getTickLength() * this.lenScale * transform.getYLength() / 2;
|
float tickLen = this.xAxis.getTickLength() * this.lenScale * transform.getYLength() / 2;
|
||||||
this.xAxis.updateTickLabels();
|
this.xAxis.updateTickLabels();
|
||||||
java.util.List<ChartText> tlabs = this.xAxis.getTickLabels();
|
java.util.List<ChartText> tlabs = this.xAxis.getTickLabels();
|
||||||
float axisLen = this.toScreenLength(xMin, y, zMin, xMax, y, zMin);
|
if (tlabs.size() > 0) {
|
||||||
skip = getLabelGap(this.xAxis.getTickLabelFont(), tlabs, axisLen);
|
float axisLen = this.toScreenLength(xMin, y, zMin, xMax, y, zMin);
|
||||||
float y1 = y > center.y ? y + tickLen : y - tickLen;
|
skip = getLabelGap(this.xAxis.getTickLabelFont(), tlabs, axisLen);
|
||||||
if (this.angleY < 90 || (this.angleY >= 180 && this.angleY < 270)) {
|
float y1 = y > center.y ? y + tickLen : y - tickLen;
|
||||||
xAlign = XAlign.LEFT;
|
if (this.angleY < 90 || (this.angleY >= 180 && this.angleY < 270)) {
|
||||||
} else {
|
xAlign = XAlign.LEFT;
|
||||||
xAlign = XAlign.RIGHT;
|
} else {
|
||||||
}
|
xAlign = XAlign.RIGHT;
|
||||||
if (this.angleX > -120) {
|
|
||||||
yAlign = YAlign.TOP;
|
|
||||||
} else {
|
|
||||||
yAlign = YAlign.BOTTOM;
|
|
||||||
}
|
|
||||||
strWidth = 0.0f;
|
|
||||||
strHeight = 0.0f;
|
|
||||||
if (this.xAxis.isDrawTickLabel()) {
|
|
||||||
this.updateTextRender(tlabs.get(0).getFont());
|
|
||||||
}
|
|
||||||
for (int i = 0; i < this.xAxis.getTickValues().length; i += skip) {
|
|
||||||
v = (float) this.xAxis.getTickValues()[i];
|
|
||||||
if (v < axesExtent.minX || v > axesExtent.maxX) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
//v = this.transform.transform_x(v);
|
if (this.angleX > -120) {
|
||||||
if (i == tlabs.size()) {
|
yAlign = YAlign.TOP;
|
||||||
break;
|
} else {
|
||||||
|
yAlign = YAlign.BOTTOM;
|
||||||
}
|
}
|
||||||
|
strWidth = 0.0f;
|
||||||
//Draw tick line
|
strHeight = 0.0f;
|
||||||
rgba = this.xAxis.getLineColor().getRGBComponents(null);
|
|
||||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
|
||||||
gl.glLineWidth(this.xAxis.getLineWidth() * this.dpiScale);
|
|
||||||
gl.glBegin(GL2.GL_LINES);
|
|
||||||
gl.glVertex3f(v, y, zMin);
|
|
||||||
gl.glVertex3f(v, y1, zMin);
|
|
||||||
gl.glEnd();
|
|
||||||
|
|
||||||
//Draw tick label
|
|
||||||
if (this.xAxis.isDrawTickLabel()) {
|
if (this.xAxis.isDrawTickLabel()) {
|
||||||
rect = drawString(gl, tlabs.get(i), v, y1, zMin, xAlign, yAlign);
|
this.updateTextRender(tlabs.get(0).getFont());
|
||||||
if (strWidth < rect.getWidth()) {
|
}
|
||||||
strWidth = (float) rect.getWidth();
|
for (int i = 0; i < this.xAxis.getTickValues().length; i += skip) {
|
||||||
|
v = (float) this.xAxis.getTickValues()[i];
|
||||||
|
if (v < axesExtent.minX || v > axesExtent.maxX) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (strHeight < rect.getHeight()) {
|
//v = this.transform.transform_x(v);
|
||||||
strHeight = (float) rect.getHeight();
|
if (i == tlabs.size()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Draw tick line
|
||||||
|
rgba = this.xAxis.getLineColor().getRGBComponents(null);
|
||||||
|
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||||
|
gl.glLineWidth(this.xAxis.getLineWidth() * this.dpiScale);
|
||||||
|
gl.glBegin(GL2.GL_LINES);
|
||||||
|
gl.glVertex3f(v, y, zMin);
|
||||||
|
gl.glVertex3f(v, y1, zMin);
|
||||||
|
gl.glEnd();
|
||||||
|
|
||||||
|
//Draw tick label
|
||||||
|
if (this.xAxis.isDrawTickLabel()) {
|
||||||
|
rect = drawString(gl, tlabs.get(i), v, y1, zMin, xAlign, yAlign);
|
||||||
|
if (strWidth < rect.getWidth()) {
|
||||||
|
strWidth = (float) rect.getWidth();
|
||||||
|
}
|
||||||
|
if (strHeight < rect.getHeight()) {
|
||||||
|
strHeight = (float) rect.getHeight();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//Draw x axis label
|
//Draw x axis label
|
||||||
if (this.xAxis.isDrawLabel()) {
|
if (this.xAxis.isDrawLabel()) {
|
||||||
ChartText label = this.xAxis.getLabel();
|
ChartText label = this.xAxis.getLabel();
|
||||||
if (label != null) {
|
if (label != null) {
|
||||||
this.updateTextRender(label.getFont());
|
this.updateTextRender(label.getFont());
|
||||||
strWidth += this.tickSpace;
|
strWidth += this.tickSpace;
|
||||||
float angle = this.toScreenAngle(xMin, y, zMin, xMax, y, zMin);
|
float angle = this.toScreenAngle(xMin, y, zMin, xMax, y, zMin);
|
||||||
angle = y < center.y ? 270 - angle : 90 - angle;
|
angle = y < center.y ? 270 - angle : 90 - angle;
|
||||||
float yShift = Math.min(-strWidth, -strWidth);
|
float yShift = Math.min(-strWidth, -strWidth);
|
||||||
if (this.angleX <= -120) {
|
if (this.angleX <= -120) {
|
||||||
yShift = -yShift;
|
yShift = -yShift;
|
||||||
|
}
|
||||||
|
float x1 = (xMin + xMax) / 2;
|
||||||
|
drawString(gl, label, x1, y1, zMin, XAlign.CENTER, yAlign, angle, 0, yShift);
|
||||||
}
|
}
|
||||||
float x1 = (xMin + xMax) / 2;
|
|
||||||
drawString(gl, label, x1, y1, zMin, XAlign.CENTER, yAlign, angle, 0, yShift);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2030,70 +2037,72 @@ public class GLPlot extends Plot {
|
|||||||
//y axis ticks
|
//y axis ticks
|
||||||
this.yAxis.updateTickLabels();
|
this.yAxis.updateTickLabels();
|
||||||
tlabs = this.yAxis.getTickLabels();
|
tlabs = this.yAxis.getTickLabels();
|
||||||
axisLen = this.toScreenLength(x, yMin, zMin, x, yMax, zMin);
|
if (tlabs.size() > 0) {
|
||||||
skip = getLabelGap(this.yAxis.getTickLabelFont(), tlabs, axisLen);
|
float axisLen = this.toScreenLength(x, yMin, zMin, x, yMax, zMin);
|
||||||
tickLen = this.yAxis.getTickLength() * this.lenScale * transform.getXLength() / 2;
|
skip = getLabelGap(this.yAxis.getTickLabelFont(), tlabs, axisLen);
|
||||||
float x1 = x > center.x ? x + tickLen : x - tickLen;
|
tickLen = this.yAxis.getTickLength() * this.lenScale * transform.getXLength() / 2;
|
||||||
if (this.angleY < 90 || (this.angleY >= 180 && this.angleY < 270)) {
|
float x1 = x > center.x ? x + tickLen : x - tickLen;
|
||||||
xAlign = XAlign.RIGHT;
|
if (this.angleY < 90 || (this.angleY >= 180 && this.angleY < 270)) {
|
||||||
} else {
|
xAlign = XAlign.RIGHT;
|
||||||
xAlign = XAlign.LEFT;
|
} else {
|
||||||
}
|
xAlign = XAlign.LEFT;
|
||||||
if (this.angleX > -120) {
|
|
||||||
yAlign = YAlign.TOP;
|
|
||||||
} else {
|
|
||||||
yAlign = YAlign.BOTTOM;
|
|
||||||
}
|
|
||||||
strWidth = 0.0f;
|
|
||||||
strHeight = 0.0f;
|
|
||||||
if (this.yAxis.isDrawTickLabel()) {
|
|
||||||
this.updateTextRender(tlabs.get(0).getFont());
|
|
||||||
}
|
|
||||||
for (int i = 0; i < this.yAxis.getTickValues().length; i += skip) {
|
|
||||||
v = (float) this.yAxis.getTickValues()[i];
|
|
||||||
if (v < axesExtent.minY || v > axesExtent.maxY) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
//v = this.transform.transform_y(v);
|
if (this.angleX > -120) {
|
||||||
if (i == tlabs.size()) {
|
yAlign = YAlign.TOP;
|
||||||
break;
|
} else {
|
||||||
|
yAlign = YAlign.BOTTOM;
|
||||||
}
|
}
|
||||||
|
strWidth = 0.0f;
|
||||||
//Draw tick line
|
strHeight = 0.0f;
|
||||||
rgba = this.yAxis.getLineColor().getRGBComponents(null);
|
|
||||||
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
|
||||||
gl.glLineWidth(this.yAxis.getLineWidth() * this.dpiScale);
|
|
||||||
gl.glBegin(GL2.GL_LINES);
|
|
||||||
gl.glVertex3f(x, v, zMin);
|
|
||||||
gl.glVertex3f(x1, v, zMin);
|
|
||||||
gl.glEnd();
|
|
||||||
|
|
||||||
//Draw tick label
|
|
||||||
if (this.yAxis.isDrawTickLabel()) {
|
if (this.yAxis.isDrawTickLabel()) {
|
||||||
rect = drawString(gl, tlabs.get(i), x1, v, zMin, xAlign, yAlign);
|
this.updateTextRender(tlabs.get(0).getFont());
|
||||||
if (strWidth < rect.getWidth()) {
|
}
|
||||||
strWidth = (float) rect.getWidth();
|
for (int i = 0; i < this.yAxis.getTickValues().length; i += skip) {
|
||||||
|
v = (float) this.yAxis.getTickValues()[i];
|
||||||
|
if (v < axesExtent.minY || v > axesExtent.maxY) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (strHeight < rect.getHeight()) {
|
//v = this.transform.transform_y(v);
|
||||||
strHeight = (float) rect.getHeight();
|
if (i == tlabs.size()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Draw tick line
|
||||||
|
rgba = this.yAxis.getLineColor().getRGBComponents(null);
|
||||||
|
gl.glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||||
|
gl.glLineWidth(this.yAxis.getLineWidth() * this.dpiScale);
|
||||||
|
gl.glBegin(GL2.GL_LINES);
|
||||||
|
gl.glVertex3f(x, v, zMin);
|
||||||
|
gl.glVertex3f(x1, v, zMin);
|
||||||
|
gl.glEnd();
|
||||||
|
|
||||||
|
//Draw tick label
|
||||||
|
if (this.yAxis.isDrawTickLabel()) {
|
||||||
|
rect = drawString(gl, tlabs.get(i), x1, v, zMin, xAlign, yAlign);
|
||||||
|
if (strWidth < rect.getWidth()) {
|
||||||
|
strWidth = (float) rect.getWidth();
|
||||||
|
}
|
||||||
|
if (strHeight < rect.getHeight()) {
|
||||||
|
strHeight = (float) rect.getHeight();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//Draw y axis label
|
//Draw y axis label
|
||||||
if (this.yAxis.isDrawLabel()) {
|
if (this.yAxis.isDrawLabel()) {
|
||||||
ChartText label = this.yAxis.getLabel();
|
ChartText label = this.yAxis.getLabel();
|
||||||
if (label != null) {
|
if (label != null) {
|
||||||
this.updateTextRender(label.getFont());
|
this.updateTextRender(label.getFont());
|
||||||
strWidth += this.tickSpace;
|
strWidth += this.tickSpace;
|
||||||
float angle = this.toScreenAngle(x, yMin, zMin, x, yMax, zMin);
|
float angle = this.toScreenAngle(x, yMin, zMin, x, yMax, zMin);
|
||||||
angle = x > center.x ? 270 - angle : 90 - angle;
|
angle = x > center.x ? 270 - angle : 90 - angle;
|
||||||
float yShift = Math.min(-strWidth, -strWidth);
|
float yShift = Math.min(-strWidth, -strWidth);
|
||||||
if (this.angleX <= -120) {
|
if (this.angleX <= -120) {
|
||||||
yShift = -yShift;
|
yShift = -yShift;
|
||||||
|
}
|
||||||
|
float y1 = (yMin + yMax) / 2;
|
||||||
|
drawString(gl, label, x1, y1, zMin, XAlign.CENTER, yAlign, angle, 0, yShift);
|
||||||
}
|
}
|
||||||
y1 = (yMin + yMax) / 2;
|
|
||||||
drawString(gl, label, x1, y1, zMin, XAlign.CENTER, yAlign, angle, 0, yShift);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2361,6 +2370,10 @@ public class GLPlot extends Plot {
|
|||||||
|
|
||||||
Rectangle2D drawString(GL2 gl, String str, Font font, Color color, float vx, float vy, float vz,
|
Rectangle2D drawString(GL2 gl, String str, Font font, Color color, float vx, float vy, float vz,
|
||||||
XAlign xAlign, YAlign yAlign, float xShift, float yShift) {
|
XAlign xAlign, YAlign yAlign, float xShift, float yShift) {
|
||||||
|
if (Draw.getStringType(str) == StringType.LATEX) {
|
||||||
|
return drawLaTex(gl, str, font, color, vx, vy, vz, xAlign, yAlign, xShift, yShift);
|
||||||
|
}
|
||||||
|
|
||||||
//Get screen coordinates
|
//Get screen coordinates
|
||||||
Vector2f coord = this.toScreen(vx, vy, vz);
|
Vector2f coord = this.toScreen(vx, vy, vz);
|
||||||
float x = coord.x;
|
float x = coord.x;
|
||||||
@ -2393,6 +2406,88 @@ public class GLPlot extends Plot {
|
|||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle2D drawLaTex(GL2 gl, String str, Font font, Color color, float vx, float vy, float vz,
|
||||||
|
XAlign xAlign, YAlign yAlign, float xShift, float yShift) {
|
||||||
|
//Get screen coordinates
|
||||||
|
Vector2f coord = this.toScreen(vx, vy, vz);
|
||||||
|
float x = coord.x;
|
||||||
|
float y = coord.y;
|
||||||
|
|
||||||
|
return drawLaTex(gl, str, font, color, x, y, xAlign, yAlign, xShift, yShift);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle2D drawLaTex(GL2 gl, String str, Font font, Color color, float x, float y,
|
||||||
|
XAlign xAlign, YAlign yAlign, float xShift, float yShift) {
|
||||||
|
// create a formula
|
||||||
|
TeXFormula formula = new TeXFormula(str);
|
||||||
|
|
||||||
|
// render the formula to an icon of the same size as the formula.
|
||||||
|
TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_TEXT, font.getSize());
|
||||||
|
|
||||||
|
// insert a border
|
||||||
|
icon.setInsets(new Insets(5, 5, 5, 5));
|
||||||
|
|
||||||
|
BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(),
|
||||||
|
BufferedImage.TYPE_INT_ARGB);
|
||||||
|
Graphics2D g2 = image.createGraphics();
|
||||||
|
|
||||||
|
//Dimension dim = Draw.getStringDimension(str, g2);
|
||||||
|
Dimension dim = new Dimension(icon.getIconWidth(), icon.getIconHeight());
|
||||||
|
switch (xAlign) {
|
||||||
|
case CENTER:
|
||||||
|
x -= dim.width * 0.5;
|
||||||
|
break;
|
||||||
|
case RIGHT:
|
||||||
|
x -= dim.width;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (yAlign) {
|
||||||
|
case CENTER:
|
||||||
|
y -= dim.height * 0.3;
|
||||||
|
break;
|
||||||
|
case TOP:
|
||||||
|
y -= dim.height;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
icon.setForeground(color);
|
||||||
|
x += xShift;
|
||||||
|
y += yShift;
|
||||||
|
icon.paintIcon(null, g2, 0, 0);
|
||||||
|
|
||||||
|
Rectangle2D rect = new Rectangle2D.Float(x, y, icon.getIconWidth(), icon.getIconHeight());
|
||||||
|
|
||||||
|
final int attribBits =
|
||||||
|
GL2.GL_ENABLE_BIT | GL2.GL_TEXTURE_BIT | GL.GL_COLOR_BUFFER_BIT |
|
||||||
|
(GL.GL_DEPTH_BUFFER_BIT | GL2.GL_TRANSFORM_BIT);
|
||||||
|
gl.glPushAttrib(attribBits);
|
||||||
|
gl.glDisable(GL.GL_DEPTH_TEST);
|
||||||
|
gl.glDisable(GL.GL_CULL_FACE);
|
||||||
|
gl.glMatrixMode(GL2.GL_PROJECTION);
|
||||||
|
gl.glPushMatrix();
|
||||||
|
gl.glLoadIdentity();
|
||||||
|
glu.gluOrtho2D(0, width, 0, height);
|
||||||
|
gl.glMatrixMode(GL2.GL_MODELVIEW);
|
||||||
|
gl.glPushMatrix();
|
||||||
|
gl.glLoadIdentity();
|
||||||
|
gl.glMatrixMode(GL.GL_TEXTURE);
|
||||||
|
gl.glPushMatrix();
|
||||||
|
gl.glLoadIdentity();
|
||||||
|
|
||||||
|
Texture texture = AWTTextureIO.newTexture(gl.getGLProfile(), image, true);
|
||||||
|
drawTexture(gl, texture, rect);
|
||||||
|
|
||||||
|
gl.glMatrixMode(GL2.GL_PROJECTION);
|
||||||
|
gl.glPopMatrix();
|
||||||
|
gl.glMatrixMode(GL2.GL_MODELVIEW);
|
||||||
|
gl.glPopMatrix();
|
||||||
|
gl.glMatrixMode(GL.GL_TEXTURE);
|
||||||
|
gl.glPopMatrix();
|
||||||
|
gl.glPopAttrib();
|
||||||
|
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle2D drawString(GL2 gl, ChartText text, float vx, float vy, float vz,
|
Rectangle2D drawString(GL2 gl, ChartText text, float vx, float vy, float vz,
|
||||||
XAlign xAlign, YAlign yAlign, float angle) {
|
XAlign xAlign, YAlign yAlign, float angle) {
|
||||||
return drawString(gl, text.getText(), text.getColor(), vx, vy, vz, xAlign, yAlign, angle,
|
return drawString(gl, text.getText(), text.getColor(), vx, vy, vz, xAlign, yAlign, angle,
|
||||||
@ -2482,17 +2577,27 @@ public class GLPlot extends Plot {
|
|||||||
|
|
||||||
void drawTitle() {
|
void drawTitle() {
|
||||||
if (title != null) {
|
if (title != null) {
|
||||||
//Rendering text string
|
float x = (float) (this.width / 2.0f);
|
||||||
Font font = title.getFont();
|
float y = this.height;
|
||||||
this.updateTextRender(font);
|
if (Draw.getStringType(title.getText()) == StringType.LATEX) {
|
||||||
textRenderer.beginRendering(this.width, this.height);
|
if (gl == null) {
|
||||||
textRenderer.setColor(title.getColor());
|
gl = GLContext.getCurrentGL().getGL2();
|
||||||
textRenderer.setSmoothing(true);
|
}
|
||||||
Rectangle2D rect = textRenderer.getBounds(title.getText().subSequence(0, title.getText().length()));
|
drawLaTex(gl, title.getText(), title.getFont(), title.getColor(),
|
||||||
float x = (float) (this.width / 2.0f) - (float) rect.getWidth() / 2.0f;
|
x, y, XAlign.CENTER, YAlign.TOP, 0, 0);
|
||||||
float y = this.height - (float) rect.getHeight();
|
} else {
|
||||||
textRenderer.draw(title.getText(), (int) x, (int) y);
|
//Rendering text string
|
||||||
textRenderer.endRendering();
|
Font font = title.getFont();
|
||||||
|
this.updateTextRender(font);
|
||||||
|
textRenderer.beginRendering(this.width, this.height);
|
||||||
|
textRenderer.setColor(title.getColor());
|
||||||
|
textRenderer.setSmoothing(true);
|
||||||
|
Rectangle2D rect = textRenderer.getBounds(title.getText().subSequence(0, title.getText().length()));
|
||||||
|
x = (float) (this.width / 2.0f) - (float) rect.getWidth() / 2.0f;
|
||||||
|
y = this.height - (float) rect.getHeight();
|
||||||
|
textRenderer.draw(title.getText(), (int) x, (int) y);
|
||||||
|
textRenderer.endRendering();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3507,6 +3612,41 @@ public class GLPlot extends Plot {
|
|||||||
gl.glDisable(GL2.GL_TEXTURE_2D);
|
gl.glDisable(GL2.GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drawTexture(GL2 gl, Texture texture, Rectangle2D rect) {
|
||||||
|
int idTexture = texture.getTextureObject(gl);
|
||||||
|
int width = texture.getWidth();
|
||||||
|
int height = texture.getHeight();
|
||||||
|
|
||||||
|
gl.glEnable(GL2.GL_TEXTURE_2D);
|
||||||
|
gl.glColor3f(1f, 1f, 1f);
|
||||||
|
gl.glBindTexture(GL2.GL_TEXTURE_2D, idTexture);
|
||||||
|
|
||||||
|
// Texture parameterization
|
||||||
|
//gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
|
||||||
|
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR_MIPMAP_LINEAR);
|
||||||
|
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
|
||||||
|
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
|
||||||
|
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);
|
||||||
|
|
||||||
|
// Draw image
|
||||||
|
gl.glBegin(GL2.GL_QUADS);
|
||||||
|
// Front Face
|
||||||
|
gl.glTexCoord2f(0.0f, 1.0f);
|
||||||
|
gl.glVertex2f((float) rect.getX(), (float) rect.getY());
|
||||||
|
gl.glTexCoord2f(1.0f, 1.0f);
|
||||||
|
gl.glVertex2f((float) rect.getMaxX(), (float) rect.getY());
|
||||||
|
gl.glTexCoord2f(1.0f, 0.0f);
|
||||||
|
gl.glVertex2f((float) rect.getMaxX(), (float) rect.getMaxY());
|
||||||
|
gl.glTexCoord2f(0.0f, 0.0f);
|
||||||
|
gl.glVertex2f((float) rect.getX(), (float) rect.getMaxY());
|
||||||
|
gl.glEnd();
|
||||||
|
gl.glFlush();
|
||||||
|
|
||||||
|
// Unbinding the texture
|
||||||
|
gl.glBindTexture(GL2.GL_TEXTURE_2D, 0);
|
||||||
|
gl.glDisable(GL2.GL_TEXTURE_2D);
|
||||||
|
}
|
||||||
|
|
||||||
void drawCircle(GL2 gl, float z, float radius, PolygonBreak bb) {
|
void drawCircle(GL2 gl, float z, float radius, PolygonBreak bb) {
|
||||||
drawCircle(gl, z, radius, bb, false);
|
drawCircle(gl, z, radius, bb, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -454,7 +454,7 @@ public class Draw {
|
|||||||
// create a formula
|
// create a formula
|
||||||
TeXFormula formula = new TeXFormula(str);
|
TeXFormula formula = new TeXFormula(str);
|
||||||
|
|
||||||
// render the formla to an icon of the same size as the formula.
|
// render the formula to an icon of the same size as the formula.
|
||||||
TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_TEXT, size);
|
TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_TEXT, size);
|
||||||
|
|
||||||
// insert a border
|
// insert a border
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth">
|
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\text">
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\axis"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\axis"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\contour"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\no_opengl"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\no_opengl"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\quiver"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\quiver"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot"/>
|
||||||
@ -13,22 +11,24 @@
|
|||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamplot"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamplot"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamslice"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamslice"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\contour"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\text"/>
|
||||||
</Path>
|
</Path>
|
||||||
<File>
|
<File>
|
||||||
<OpenedFiles>
|
<OpenedFiles>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_cma_base_grid_3d.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_cma_base_grid_3d.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\quiver\quiver3_2.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\quiver\quiver3_2.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth\streamslice_1.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\contour\contour_log_1.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth\quiver3_1.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\text\text_latex.py"/>
|
||||||
</OpenedFiles>
|
</OpenedFiles>
|
||||||
<RecentFiles>
|
<RecentFiles>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_cma_base_grid_3d.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_cma_base_grid_3d.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\quiver\quiver3_2.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\quiver\quiver3_2.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth\streamslice_1.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\contour\contour_log_1.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth\quiver3_1.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\text\text_latex.py"/>
|
||||||
</RecentFiles>
|
</RecentFiles>
|
||||||
</File>
|
</File>
|
||||||
<Font>
|
<Font>
|
||||||
@ -36,5 +36,5 @@
|
|||||||
</Font>
|
</Font>
|
||||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||||
<Figure DoubleBuffering="true"/>
|
<Figure DoubleBuffering="true"/>
|
||||||
<Startup MainFormLocation="-7,0" MainFormSize="1345,802"/>
|
<Startup MainFormLocation="-7,0" MainFormSize="1366,803"/>
|
||||||
</MeteoInfo>
|
</MeteoInfo>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user