mirror of https://github.com/rusefi/jzy3d-api.git
Fixed colorbar margins in the native case
This commit is contained in:
parent
1f5a40278d
commit
78dc0d96d3
|
@ -66,34 +66,36 @@ public class AWTImageViewport extends AbstractViewportManager implements IImageV
|
|||
int xPosition = 0;
|
||||
int yPosition = 0;
|
||||
|
||||
System.out.println("AWTImageViewport : im : " + imageWidth + " screen : " + screenWidth + " margin : " + margin.getWidth());
|
||||
|
||||
// If image is smaller than viewport, move it a bit to let it appear in the center
|
||||
if (imageWidth < screenWidth) {
|
||||
if(margin.getLeft()!=margin.getRight()) {
|
||||
xPosition = Math.round(screenWidth / 2f - (imageWidth / 2f + margin.getWidth()));
|
||||
|
||||
}
|
||||
else {
|
||||
xPosition = Math.round((float) screenWidth / 2 - (float) imageWidth / 2);
|
||||
|
||||
// If margin are asymetric, shift by taking them into account
|
||||
if(margin.getLeft()!=margin.getRight()) {
|
||||
xPosition += (margin.getLeft() - margin.getRight());
|
||||
}
|
||||
}
|
||||
else
|
||||
// If image is bigger than viewport, unzoom it a bit to let it fit the dimensions
|
||||
else if(imageWidth > screenWidth){
|
||||
xZoom = ((float) screenWidth) / ((float) imageWidth);
|
||||
|
||||
}
|
||||
|
||||
// If image is smaller than viewport, move it a bit to let it appear in the center
|
||||
if (imageHeight < screenHeight) {
|
||||
//int shiftForMargin = 0;
|
||||
|
||||
// TODO : clarify this
|
||||
|
||||
yPosition = Math.round((float) screenHeight / 2 - ((float) imageHeight / 2));
|
||||
|
||||
if(margin.getTop()!=margin.getBottom()) {
|
||||
//shiftForMargin = Math.round(margin.getHeight()/2);
|
||||
yPosition = Math.round(screenHeight / 2f - (imageHeight / 2f - margin.getHeight()/2f) /*margin.getTop())*/);
|
||||
yPosition += (margin.getBottom()-margin.getTop());
|
||||
}
|
||||
else {
|
||||
yPosition = Math.round((float) screenHeight / 2 - ((float) imageHeight / 2));
|
||||
}
|
||||
}
|
||||
else
|
||||
// If image is bigger than viewport, unzoom it a bit to let it fit the dimensions
|
||||
else if(imageWidth > screenWidth) {
|
||||
yZoom = ((float) screenHeight) / ((float) imageHeight);
|
||||
|
||||
}
|
||||
//System.out.println("AWTImageViewport posi.x:" + xPosition + " posi.y:" + xPosition);
|
||||
//System.out.println("AWTImageViewport zoom.x:" + xZoom + " zoom.y:" + yZoom);
|
||||
//System.out.println("AWTImageViewport size.x:" + imageWidth + " size.y:" + imageHeight);
|
||||
|
|
|
@ -47,6 +47,7 @@ public class hello extends GLCanvas {
|
|||
/* initialize viewing values */
|
||||
myGL.glMatrixMode(GL.GL_PROJECTION);
|
||||
myGL.glLoadIdentity();
|
||||
|
||||
myGL.glOrtho(0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ public class View2DLayout_Debug extends AbstractAWTRenderer2d implements AWTRend
|
|||
|
||||
x= viewport.getX();
|
||||
int yminDim= yBar+lineHeight;
|
||||
w =Math.round(colorbar.getMinimumDimension().width*pixelScale.getX());
|
||||
w = Math.round(colorbar.getMinimumDimension().width*pixelScale.getX());
|
||||
h = Math.round(colorbar.getMinimumDimension().height+pixelScale.getY());
|
||||
|
||||
g2d.setStroke(new BasicStroke(2));
|
||||
|
@ -160,6 +160,7 @@ public class View2DLayout_Debug extends AbstractAWTRenderer2d implements AWTRend
|
|||
//maxTextWidth =
|
||||
|
||||
g2d.drawString("Colorbar.MinDim", x, yminDim);
|
||||
g2d.drawString(colorbar.getMinimumDimension().toString(), x, yminDim+g2d.getFont().getSize()+1);
|
||||
|
||||
g2d.setStroke(new BasicStroke(1));
|
||||
|
||||
|
|
Loading…
Reference in New Issue