Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering with LWJGL #277

Open
wants to merge 117 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
bde1da5
Init LWJGL
May 29, 2022
2e9a0cb
adding classpath check
May 29, 2022
3662a30
Bump to version 2.1.1-SNAPSHOT
jzy3d May 31, 2022
353b711
Remap perf in ms
jzy3d May 31, 2022
66323f4
Merge branch 'master' of github.com:jzy3d/jzy3d-api
jzy3d May 31, 2022
5cc305b
Init HiDPI layout tests
jzy3d May 31, 2022
a8cae24
Add test on ViewAndColorbarsLayout
jzy3d May 31, 2022
e5d3b02
Added Oliver contribution
jzy3d May 31, 2022
c776aea
.
jzy3d May 31, 2022
5b21418
Using the same test for Native and EmulGL view layout
jzy3d May 31, 2022
c677f16
Add tests
jzy3d May 31, 2022
bd4baa7
.
jzy3d Jun 1, 2022
4eba82f
Adding new margin class, added tests, let colorbar width be scaled wi…
jzy3d Jun 2, 2022
38961dd
Scaling 2D margin with pixel scale for native
jzy3d Jun 2, 2022
df1dbe2
AWT 2D chart perfectly support pixelscale change
jzy3d Jun 2, 2022
d5629c0
pre del chart view
jzy3d Jun 7, 2022
19d4a02
Considering colorbar margins, started to deal with asymetric margin
jzy3d Jun 7, 2022
46cc7f9
.
jzy3d Jun 8, 2022
6ebaa03
Margins with integers instead
jzy3d Jun 9, 2022
8725195
properly show right margin in debug mode for emulgl
jzy3d Jun 9, 2022
1f5a402
Fix EmulGL view size bug
jzy3d Jun 9, 2022
78dc0d9
Fixed colorbar margins in the native case
jzy3d Jun 9, 2022
aef5f3a
.
jzy3d Jun 9, 2022
60951e7
.
jzy3d Jun 9, 2022
f99e90f
.
jzy3d Jun 9, 2022
5d89ed9
AWTImageViewport able to apply margin properly in HiDPI and non HiDPI…
jzy3d Jun 10, 2022
7007c61
fix test
jzy3d Jun 10, 2022
847aa46
Remove view.shoot conditions to keep renderer.init method invocable
jzy3d Jun 11, 2022
c145ad5
Remove view.shoot conditions to keep renderer.init method invocable
jzy3d Jun 11, 2022
42a4f96
Added font size selector
jzy3d Jun 12, 2022
75fbdb5
.
jzy3d Jun 12, 2022
87de896
.
jzy3d Jun 13, 2022
cf1f8d0
A bit more test
jzy3d Jun 13, 2022
c755902
EmulGL colorbar margin almost working in HiDPI
jzy3d Jun 13, 2022
f45f431
.
jzy3d Jun 13, 2022
5126ac0
remove shrink colorbar
jzy3d Jun 13, 2022
3e67484
Add layout settings clone methods
jzy3d Jun 13, 2022
fbbba30
debug in progress
jzy3d Jun 14, 2022
a996d95
Fix X tick and axis labels overlapping with EmulGL
jzy3d Jun 15, 2022
d1c8737
Fix few tests
jzy3d Jun 15, 2022
d62ae7a
Improve tests
jzy3d Jun 15, 2022
e3fcfbe
Fixed emulGL margin processing with/without HiDPI
jzy3d Jun 15, 2022
0e9a6c1
Configure mutation testing
jzy3d Jun 16, 2022
1d8a462
Fix EmulGL Y axis label position
jzy3d Jun 16, 2022
68aed9c
Fixed EmulGL colorbar layout
jzy3d Jun 16, 2022
069cce7
Fix EMulGL test
jzy3d Jun 16, 2022
4d06d2a
bundle
jzy3d Jun 16, 2022
4d1fed6
bundle
jzy3d Jun 16, 2022
2b07093
clean
jzy3d Jun 17, 2022
dcc268f
Fix vertical colorbar position for EMulGL charts
jzy3d Jun 17, 2022
a633094
Better canvas pixel scale getters. Add checks to view pixel scale lis…
jzy3d Jun 17, 2022
96ade95
Update baseline images
jzy3d Jun 17, 2022
75ea6a4
Merge branch 'feature/layoutWithHiDPI' of github.com:jzy3d/jzy3d-api …
jzy3d Jun 17, 2022
7ea7e2e
Allow reconfiguring legend's pixel scale upon view pixel scale update
jzy3d Jun 17, 2022
7cb85ae
Add pauses to let test pass on Linux. Weird edit
jzy3d Jun 17, 2022
feee2c7
.
jzy3d Jun 17, 2022
f3c7f72
Wait a bit more
jzy3d Jun 20, 2022
2c02543
Let windows test work
jzy3d Jun 20, 2022
86d7d74
Merge branch 'feature/layoutWithHiDPI' of
jzy3d Jun 20, 2022
195b758
Hack layout for the AWT+Windows+HiDPI case
jzy3d Jun 20, 2022
07c4349
add bin to gitignore
jzy3d Jun 20, 2022
7bae9df
Merge branch 'feature/layoutWithHiDPI' of github.com:jzy3d/jzy3d-api …
jzy3d Jun 20, 2022
9e27582
Comment part of the Windows fix
jzy3d Jun 20, 2022
ca8dfd7
Merge pull request #281 from jzy3d/feature/layoutWithHiDPI
jzy3d Jun 20, 2022
f92a13f
Merge pull request #280 from jzy3d/feature/arrowFor3DVectorFields
jzy3d Jun 20, 2022
3ed4e24
Add line strip doc
jzy3d Jun 21, 2022
fb1eb02
Improve trigonometric tick renderer and add tests
jzy3d Jun 21, 2022
24abcee
.
jzy3d Jun 21, 2022
7c297c7
Avoid NPE when chart is unregistered
Jun 22, 2022
1be3bee
Let AWT mouse picker implement mouse dragged
Jun 23, 2022
f1245d1
Add mapper 2D
jzy3d Jun 23, 2022
9f78fd4
.
Jun 23, 2022
85b0acb
Merge branch 'master' into feature/dragObjectsWithMouse
jzy3d Jun 23, 2022
632af16
Add projection utils
jzy3d Jun 23, 2022
a1c9f34
improve primitives for gradients
jzy3d Jun 27, 2022
2fe0460
init 2D views
jzy3d Jun 27, 2022
ffe3f91
init 2D views for XZ/YZ
jzy3d Jun 28, 2022
70ce1ec
Tick placement of 2D charts XZ and YZ
jzy3d Jun 29, 2022
c5a713d
Axis label placement of 2D charts XZ and YZ, adding a more handy view…
jzy3d Jun 29, 2022
2561e3c
Generalize view2D/view3D toggle
jzy3d Jun 29, 2022
8bb430d
Workaround XZ and YZ projections on EmulGL, relates to issue 274
jzy3d Jun 30, 2022
90152f9
Update baselines for macOS 10.12
jzy3d Jun 30, 2022
435cf12
Update baseline images for macOS 11.4 & Apple M1
jzy3d Jun 30, 2022
1d4da5b
Merge branch 'feature/alternative2DViews' of github.com:jzy3d/jzy3d-a…
jzy3d Jun 30, 2022
e2b1dd9
Accurate depth range processing for all 2D charts (XY, XZ, YZ)
jzy3d Jun 30, 2022
8f46638
Remove useless method
jzy3d Jun 30, 2022
ffc84e1
Merge pull request #285 from jzy3d/feature/alternative2DViews
jzy3d Jul 4, 2022
e3cf9ae
Started to flip X axis in XY view
jzy3d Jul 4, 2022
1dc5945
Adding cases
jzy3d Jul 6, 2022
7939bf4
.
jzy3d Jul 8, 2022
f942a9b
Allow disabling smart text renderer to prevent hangs
jzy3d Jul 8, 2022
7fe2bfc
2D XY charts : Allow Flipping X axis only, Y axis only or both
jzy3d Jul 8, 2022
63361f6
2D XZ and YZ charts : Allow Flipping vertical axis only, horizontal a…
jzy3d Jul 8, 2022
df724fb
Partial fix for Perspective projection
jzy3d Jul 12, 2022
69d8db1
Fix the YZ charts flipping cases
jzy3d Jul 12, 2022
49b3840
Improve AxisLableProcessor readability
jzy3d Jul 12, 2022
8127d10
clean code
jzy3d Jul 12, 2022
a74a331
clean code
jzy3d Jul 12, 2022
2a3f6ce
Merge pull request #290 from jzy3d/feature/flip2DViews
jzy3d Jul 12, 2022
b83ac39
remove swt-core that is empty!
jzy3d Jul 12, 2022
f775034
.
jzy3d Jul 13, 2022
3d79fc2
.
Jul 25, 2022
589e3f7
doc
jzy3d Jul 26, 2022
6ac519e
Merge branch 'master' of github.com:jzy3d/jzy3d-api
jzy3d Jul 26, 2022
35b013b
Adding smooth line
Jul 28, 2022
fb6c3a0
Merge branch 'master' of github.com:jzy3d/jzy3d-api into master
Jul 28, 2022
fecb536
Workaround a Swing bug related to 2D view updates
Jul 28, 2022
9208118
Ensure EmulGLPainter is able to return its appropriate target windowi…
Jul 28, 2022
441aabe
working on swing issue
Jul 28, 2022
8573359
render twice after a viewpoint change
Jul 28, 2022
865a8eb
Init LWJGL
May 29, 2022
db1a8bb
adding classpath check
May 29, 2022
b28b373
WIP
Jul 28, 2022
8e60bd8
merge and let LWJGL painter build
Jul 28, 2022
1452b43
adding GLU
Aug 2, 2022
1dd717f
basic chart working
Aug 3, 2022
8e87d90
rendering image in viewport
Aug 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ target/
.settings
.idea/
**/.idea/

**/bin/

# OS specific folder data files
.DS_Store
Expand Down
6 changes: 3 additions & 3 deletions doc/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
* Run ITTests of the extension APIs (macOS 10.12)

## Deploy
* Generate and upload Javadoc
* Deploy JARs
* Generate and upload Javadoc `mvn javadoc:aggregate`
* Deploy JARs `mvn deploy`

## Prepare next version
* Bump all projects version to next version
* Bump all projects version to next version `mvn release:prepare`

## Publish
* Update website with this new version content
Expand Down
11 changes: 10 additions & 1 deletion jzy3d-core-awt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
<artifactId>jzy3d-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jzy3d-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>

</dependencies>

</project>
</project>
44 changes: 28 additions & 16 deletions jzy3d-core-awt/src/main/java/org/jzy3d/chart/AWTChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import org.jzy3d.plot3d.primitives.axis.layout.AxisLayout;
import org.jzy3d.plot3d.rendering.canvas.Quality;
import org.jzy3d.plot3d.rendering.legends.colorbars.AWTColorbarLegend;
import org.jzy3d.plot3d.rendering.legends.colorbars.IColorbarLegend;
import org.jzy3d.plot3d.rendering.view.AWTRenderer2d;
import org.jzy3d.plot3d.rendering.view.AWTView;
import org.jzy3d.plot3d.rendering.view.View;

public class AWTChart extends Chart {
public AWTChart(IChartFactory components, Quality quality) {
Expand All @@ -19,33 +21,43 @@ protected AWTChart() {
super();
}

public void addRenderer(AWTRenderer2d renderer2d) {
getAWTView().addRenderer2d(renderer2d);
public void add(AWTRenderer2d renderer2d) {
addRenderer(renderer2d);
}

public void removeRenderer(AWTRenderer2d renderer2d) {
getAWTView().removeRenderer2d(renderer2d);
public void addRenderer(AWTRenderer2d renderer2d) {
getView().addRenderer2d(renderer2d);
}

public void remove(AWTRenderer2d renderer2d) {
removeRenderer(renderer2d);
}

public AWTView getAWTView() {
return (AWTView) view;

public void removeRenderer(AWTRenderer2d renderer2d) {
getView().removeRenderer2d(renderer2d);
}

public AWTColorbarLegend colorbar(Drawable drawable) {
return colorbar(drawable, null, getView().getAxis().getLayout());
return colorbar(drawable, getView().getAxis().getLayout());
}

public AWTColorbarLegend colorbar(Drawable drawable, AxisLayout layout) {
return colorbar(drawable, null, layout);
}

public AWTColorbarLegend colorbar(Drawable drawable, Dimension minDimension, AxisLayout layout) {
AWTColorbarLegend colorbar = new AWTColorbarLegend(drawable, layout);

if(minDimension!=null)
colorbar.setMinimumDimension(minDimension);

AWTColorbarLegend colorbar = new AWTColorbarLegend(drawable, layout, layout.getMainColor(), view.getBackgroundColor());
drawable.setLegend(colorbar);
return colorbar;
}

@Override
public AWTColorbarLegend getColorbar() {
AWTColorbarLegend bar = (AWTColorbarLegend)super.getColorbar();
return bar;
}


@Override
public AWTView getView() {
return (AWTView)super.getView();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ public void dispose() {
*/
@Override
public void mousePressed(MouseEvent e) {
if(getChart().getView().is2D()) {
return;
}
if(getChart()!=null) {
if(getChart().getView().is2D()) {
return;
}
}

if (handleSlaveThread(e))
return;
Expand All @@ -73,9 +75,11 @@ public void mousePressed(MouseEvent e) {
/** Compute shift or rotate */
@Override
public void mouseDragged(MouseEvent e) {
if(getChart().getView().is2D()) {
return;
}
if(getChart()!=null) {
if(getChart().getView().is2D()) {
return;
}
}

// Check if mouse rate limiter wish to forbid this mouse drag instruction
if(rateLimiter!=null && !rateLimiter.rateLimitCheck()) {
Expand Down Expand Up @@ -103,10 +107,12 @@ else if (AWTMouseUtilities.isRightDown(e)) {
/** Compute zoom */
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if(getChart().getView().is2D()) {
return;
}

if(getChart()!=null) {
if(getChart().getView().is2D()) {
return;
}
}

// Check if mouse rate limiter wish to forbid this mouse drag instruction
if(rateLimiter!=null && !rateLimiter.rateLimitCheck()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ public class AWTColorbarImageGenerator extends AWTAbstractImageGenerator
public static final int MIN_BAR_HEIGHT = 100;

protected ColorMapper mapper;
protected ITickProvider provider;
protected ITickRenderer renderer;
protected ITickProvider tickProvider;
protected ITickRenderer tickRenderer;
protected double min;
protected double max;

public static int BAR_WIDTH_DEFAULT = 20;
public static int TEXT_TO_BAR_DEFAULT = 2;

protected int barWidth;
protected int textToBarHorizontalMargin = 2;
protected int textToBarHorizontalMargin = TEXT_TO_BAR_DEFAULT;
protected int maxTextWidth;

protected boolean addTextHeightToVerticalMargin = false;

Expand All @@ -45,8 +48,8 @@ public AWTColorbarImageGenerator(IColorMap map, float min, float max, ITickProvi
public AWTColorbarImageGenerator(ColorMapper mapper, ITickProvider provider,
ITickRenderer renderer) {
this.mapper = mapper;
this.provider = provider;
this.renderer = renderer;
this.tickProvider = provider;
this.tickRenderer = renderer;
this.min = mapper.getMin();
this.max = mapper.getMax();

Expand All @@ -62,8 +65,8 @@ public BufferedImage toImage(int width, int height) {

/** Renders the colorbar to an image. */
public BufferedImage toImage(int width, int height, int barWidth) {
if (barWidth > width)
return null;
//if (barWidth > width)
// return null;

this.barWidth = barWidth;

Expand All @@ -75,9 +78,9 @@ public BufferedImage toImage(int width, int height, int barWidth) {

configureText(graphic);
drawBackground(width, height, graphic);
drawBarColors(height, this.barWidth/*getScaledBarWidth()*/, graphic);
drawBarContour(height, this.barWidth/*getScaledBarWidth()*/, graphic);
drawTextAnnotations(height, this.barWidth/*getScaledBarWidth()*/, graphic);
drawBarColors(height, getScaledBarWidth(), graphic);
drawBarContour(height, getScaledBarWidth(), graphic);
drawTextAnnotations(height, getScaledBarWidth(), graphic);
return image;
}

Expand All @@ -95,7 +98,7 @@ public BufferedImage toImage(int width, int height, int barWidth) {
protected void drawBarContour(int height, int barWidth, Graphics2D graphic) {

int finalY = 0;
int finalH = height;
int finalH = height-1; // let bottom contour appear in the image

// add little space to avoid cutting the text
// on top and bottom of colorbar
Expand All @@ -118,7 +121,7 @@ protected void drawBarContour(int height, int barWidth, Graphics2D graphic) {
protected void drawBarColors(int height, int barWidth, Graphics2D graphic) {

int finalFrom = 0;
int finalTo = height;
int finalTo = height-1;

// add little space to avoid cutting the text
// on top and bottom of colorbar
Expand All @@ -140,8 +143,8 @@ protected void drawBarColors(int height, int barWidth, Graphics2D graphic) {
}

protected void drawTextAnnotations(int height, int barWidth, Graphics2D graphic) {
if (provider != null) {
double[] ticks = provider.generateTicks(min, max);
if (tickProvider != null) {
double[] ticks = tickProvider.generateTicks(min, max);

//System.out.println("AWTColorbarImageGen : min=" + min + " max=" + max);

Expand All @@ -158,7 +161,7 @@ protected void drawTextAnnotations(int height, int barWidth, Graphics2D graphic)
int ypos = (int) (height - (heightNoText * ratioOfRange));


String txt = renderer.format(ticks[t]);
String txt = tickRenderer.format(ticks[t]);
graphic.drawString(txt, xpos, ypos);
}
}
Expand All @@ -174,7 +177,7 @@ public void setPixelScale(Coord2d pixelScale) {

/* */

protected int getScaledBarWidth() {
public int getScaledBarWidth() {
if(pixelScale!=null) {
return (int)(barWidth * pixelScale.x);
}
Expand All @@ -183,18 +186,10 @@ protected int getScaledBarWidth() {
}
}

/**
* Compute the optimal image width to contain the text as defined by the tick provided and
* renderer.
*/
public int getPreferedWidth(IPainter painter) {
int maxWidth = getMaxTickLabelWidth(painter);
return getPreferedWidth(maxWidth);
public int getBarWidth() {
return barWidth;
}

protected int getPreferedWidth(int maxTextWidth) {
return maxTextWidth + textToBarHorizontalMargin + BAR_WIDTH_DEFAULT;
}

public int getTextToBarHorizontalMargin() {
return textToBarHorizontalMargin;
Expand All @@ -204,21 +199,72 @@ public void setTextToBarHorizontalMargin(int textToBarHorizontalMargin) {
this.textToBarHorizontalMargin = textToBarHorizontalMargin;
}

protected int getMaxTickLabelWidth(IPainter painter) {
/**
* Compute the optimal image width to contain the text as defined by the tick provided and
* renderer.
*/
public int getPreferredWidth(IPainter painter) {
maxTextWidth = getMaxTickLabelWidth(painter);

//System.out.println("AWTColorbarImageGen : max txt width " + maxTextWidth);

// we unscale it : we here use a graphics2D context that consider
// text scale by itself. As font is globally magnified, mainly for JOGL
// text renderer, we will unscale it for processing the width

int maxTextActual = maxTextWidth;

if(pixelScale.x>0)
maxTextActual = Math.round(maxTextWidth / pixelScale.x);

//System.out.println("AWTColorbarImageGen : max txt act " + maxTextActual + " " + pixelScale);

return getPreferredWidth(maxTextActual);
}

protected int getPreferredWidth(int maxTextWidth) {
return maxTextWidth + getTextToBarHorizontalMargin() + getBarWidth();
}

/**
* Only valid after a call to {@link #getPreferredWidth(IPainter)}
* @return
*/
public int getMaxTextWidth() {
return maxTextWidth;
}

public int getMaxTickLabelWidth(IPainter painter) {
int maxWidth = 0;
if (provider != null) {
double[] ticks = provider.generateTicks(min, max);
if (tickProvider != null) {
double[] ticks = tickProvider.generateTicks(min, max);
String tickLabel;
for (int t = 0; t < ticks.length; t++) {
tickLabel = renderer.format(ticks[t]);
tickLabel = tickRenderer.format(ticks[t]);

int stringWidth = painter.getTextLengthInPixels(font, tickLabel);

//System.out.println("Gen : " + stringWidth + " for " + tickLabel);
if (maxWidth < stringWidth) {
maxWidth = stringWidth;
}
}
}
return maxWidth;
}

public ITickProvider getTickProvider() {
return tickProvider;
}

public void setTickProvider(ITickProvider tickProvider) {
this.tickProvider = tickProvider;
}

public ITickRenderer getTickRenderer() {
return tickRenderer;
}

public void setTickRenderer(ITickRenderer tickRenderer) {
this.tickRenderer = tickRenderer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public static void drawString(Graphics2D g2d, Font font, boolean useOSFontRender
}
}

public static int stringWidth(String string) {
BufferedImage i = new BufferedImage(0,0, BufferedImage.TYPE_4BYTE_ABGR);

return stringWidth(i.createGraphics(), string);
}
public static int stringWidth(Graphics2D g2d, String string) {
FontMetrics fm = g2d.getFontMetrics();
if (fm != null) {
Expand Down
Loading