mirror of https://github.com/rusefi/jzy3d-api.git
Improve getPixelScale() to rely on the underlying JOGL surface independently of the wrapping Canvas
This commit is contained in:
parent
9ddfa901bf
commit
ffb5d16d63
|
@ -35,13 +35,13 @@ public class AWTScatterMouseSelector extends AWTAbstractMouseSelector {
|
|||
scatter.setHighlighted(i, true);
|
||||
}
|
||||
|
||||
private Coord2d getPixelScale() {
|
||||
if(chart.getQuality().isPreserveViewportSize()) {
|
||||
protected Coord2d getPixelScale() {
|
||||
/*if(chart.getQuality().isPreserveViewportSize()) {
|
||||
return new Coord2d(1,1);
|
||||
}
|
||||
else {
|
||||
else {*/
|
||||
return canvas.getPixelScale();
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -92,7 +92,7 @@ public interface ICanvas {
|
|||
* <ul>
|
||||
*
|
||||
* @see {@link ScalableSurface#setSurfaceScale(float[])} in JOGL javadoc for more informations
|
||||
* @see {@link #getPixelScale()} similar but non symetric method
|
||||
* @see {@link #getPixelScale()} similar but may be non symetric
|
||||
*
|
||||
*/
|
||||
public void setPixelScale(float[] scale);
|
||||
|
@ -100,9 +100,6 @@ public interface ICanvas {
|
|||
/**
|
||||
* Provide pixel scale as feasible by the Hardware, OS, and JVM, independently of what was asked
|
||||
* by {@link #setPixelScale(float[])}. Hence the two functions may not be consistent together.
|
||||
*
|
||||
* Implementations may return (1,1) even if HiDPI exists on hardware, especially on Java 8. Java
|
||||
* 9+ provide canvas with HiDPI detection.
|
||||
*/
|
||||
public Coord2d getPixelScale();
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ public class EmulGLCanvas extends GLCanvas implements IScreenCanvas, IMonitorabl
|
|||
|
||||
@Override
|
||||
public void setPixelScale(float[] scale) {
|
||||
Logger.getLogger(EmulGLCanvas.class).info("Not implemented. Pixel scale is driven by AWT Canvas itself and jGL adapts to it");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,5 +12,7 @@ public class OffscreenChartFactory extends AWTChartFactory {
|
|||
super(new OffscreenWindowFactory());
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
getPainterFactory().setOffscreen(width, height);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package org.jzy3d.plot3d.rendering.canvas;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.jzy3d.chart.IAnimator;
|
||||
|
@ -104,9 +102,7 @@ public class CanvasAWT extends GLCanvas implements IScreenCanvas, INativeCanvas
|
|||
*/
|
||||
@Override
|
||||
public Coord2d getPixelScale() {
|
||||
Graphics2D g2d = (Graphics2D) getGraphics();
|
||||
AffineTransform globalTransform = g2d.getTransform();
|
||||
return new Coord2d(globalTransform.getScaleX(), globalTransform.getScaleY());
|
||||
return new Coord2d((int)(getSurfaceWidth()/(float)getWidth()), (int)(getSurfaceHeight()/(float)getHeight()));
|
||||
}
|
||||
|
||||
double pixelScaleX;
|
||||
|
|
|
@ -86,12 +86,11 @@ public class CanvasNewtAwt extends Panel implements IScreenCanvas, INativeCanvas
|
|||
else
|
||||
window.setSurfaceScale(new float[] {1f, 1f});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Coord2d getPixelScale() {
|
||||
Graphics2D g2d = (Graphics2D) getGraphics();
|
||||
AffineTransform globalTransform = g2d.getTransform();
|
||||
return new Coord2d(globalTransform.getScaleX(), globalTransform.getScaleY());
|
||||
return new Coord2d((int) (window.getSurfaceWidth() / (float) getWidth()),
|
||||
(int) (window.getSurfaceHeight() / (float) getHeight()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package org.jzy3d.plot3d.rendering.canvas;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jzy3d.chart.IAnimator;
|
||||
import org.jzy3d.chart.factories.IChartFactory;
|
||||
import org.jzy3d.chart.factories.NativePainterFactory;
|
||||
|
@ -17,7 +14,6 @@ import org.jzy3d.painters.NativeDesktopPainter;
|
|||
import org.jzy3d.plot3d.rendering.scene.Scene;
|
||||
import org.jzy3d.plot3d.rendering.view.Renderer3d;
|
||||
import org.jzy3d.plot3d.rendering.view.View;
|
||||
|
||||
import com.jogamp.nativewindow.ScalableSurface;
|
||||
import com.jogamp.opengl.GL;
|
||||
import com.jogamp.opengl.GLAutoDrawable;
|
||||
|
@ -85,9 +81,7 @@ public class CanvasSwing extends GLJPanel implements IScreenCanvas, INativeCanva
|
|||
|
||||
@Override
|
||||
public Coord2d getPixelScale() {
|
||||
Graphics2D g2d = (Graphics2D) getGraphics();
|
||||
AffineTransform globalTransform = g2d.getTransform();
|
||||
return new Coord2d(globalTransform.getScaleX(), globalTransform.getScaleY());
|
||||
return new Coord2d((int)(getSurfaceWidth()/(float)getWidth()), (int)(getSurfaceHeight()/(float)getHeight()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package org.jzy3d.chart.factories;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
@ -17,7 +14,6 @@ import org.jzy3d.plot3d.rendering.canvas.Quality;
|
|||
import org.jzy3d.plot3d.rendering.scene.Scene;
|
||||
import org.jzy3d.plot3d.rendering.view.Renderer3d;
|
||||
import org.jzy3d.plot3d.rendering.view.View;
|
||||
|
||||
import com.jogamp.nativewindow.ScalableSurface;
|
||||
import com.jogamp.newt.event.KeyListener;
|
||||
import com.jogamp.newt.event.MouseListener;
|
||||
|
@ -98,8 +94,7 @@ public class CanvasNewtSWT extends Composite implements IScreenCanvas, INativeCa
|
|||
|
||||
@Override
|
||||
public Coord2d getPixelScale() {
|
||||
Logger.getLogger(CanvasNewtSWT.class).info("getPixelScale() not implemented. Will return {1,1}");
|
||||
return new Coord2d(1, 1);
|
||||
return new Coord2d((int)(window.getSurfaceWidth()/(float)getSize().x), (int)(window.getSurfaceHeight()/(float)getSize().y));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue