Skip to main content

[JAI] JadeDisplay initial display patch

3 replies [Last post]
Anonymous

Hey all...

There's a bug in JadeDisplay where it sometimes does not paint the image
when it initially comes up... you have to resize the window for it to
work. It only happens in certain circumstances. Anyway, we fixed this
bug a while back but I neglected to post it publicly. So here it is.
You should be able to apply this via:

patch -i JadeDisplay_patch1.txt JadeDisplay.java

from a Unix system (save a copy first!). Other development environments
may also have some version of patch, or you can do it the hard way
(manually).

Same license terms, disclaimers, etc. as the original release.

Enjoy...

-Bob

Bob Deen @ NASA-JPL Multimission Image Processing Lab
Bob.Deen@jpl.nasa.gov

*** ../JadeDisplay.java Wed Apr 30 15:55:51 2008
--- ./JadeDisplay.java Wed Jul 21 10:19:07 2010
***************
*** 275,283 ****

//!!!! updates to insets??!
/** Caches insets */
! protected Insets _insets = new Insets(0,0,0,0);
/** Insets as a clipping rectangle */
! protected Rectangle _insets_clip;
/** Conversion between screen and image coordinates (img = scr + scr2img) */
protected int _scr2imgX, _scr2imgY;

--- 275,285 ----

//!!!! updates to insets??!
/** Caches insets */
! // Initialized to null to serve as a flag indicating if _insets have
! // been properly set.
! protected Insets _insets = null;
/** Insets as a clipping rectangle */
! protected Rectangle _insets_clip = new Rectangle(0, 0, 0, 0);
/** Conversion between screen and image coordinates (img = scr + scr2img) */
protected int _scr2imgX, _scr2imgY;

***************
*** 457,463 ****
/***********************************************************************
* Constructs a JadeDisplay to display a RenderedImage with default
* origin (null), repaint policy (REPAINT_CACHE),
! * and double buffer disable flag (true).
* @see #JadeDisplay(RenderedImage, Point, int, boolean)
*/
public JadeDisplay(RenderedImage im)
--- 459,465 ----
/***********************************************************************
* Constructs a JadeDisplay to display a RenderedImage with default
* origin (null), repaint policy (REPAINT_CACHE),
! * and double buffer disable flag (false).
* @see #JadeDisplay(RenderedImage, Point, int, boolean)
*/
public JadeDisplay(RenderedImage im)
***************
*** 779,784 ****
--- 781,787 ----
* {
* if (isDeferredTile || isNoErase)
* return;
+ * g.setColor(this.getBackground());
* g.fillRect(x, y, width, height);
* }
*

***************
*** 797,802 ****
--- 800,806 ----
{
if (isDeferredTile || isNoErase)
return;
+ g.setColor(this.getBackground());
g.fillRect(x, y, width, height);
}

***************
*** 806,812 ****
*/
protected void handleResize()
{
! _insets = getInsets(_insets);

// Insets as a clipping rectangle (w/h)
//!!!! CHANGE THIS if the insets change
--- 810,820 ----
*/
protected void handleResize()
{
! // Don't do anything if component's size has not been
! // properly set.
! if ((getWidth() == 0) || (getHeight() == 0))
! return;
! _insets = getInsets();

// Insets as a clipping rectangle (w/h)
//!!!! CHANGE THIS if the insets change
***************
*** 843,849 ****
{
// Insets as a clipping rectangle (w/h)
//!!!! CHANGE THIS if the insets change
! _insets = getInsets(_insets);

// Set the preferred size of the component to the size of the
// image. The caller can adjust the actual size if desired.
--- 851,859 ----
{
// Insets as a clipping rectangle (w/h)
//!!!! CHANGE THIS if the insets change
! // We use local variable to store insets. Member variable _insets
! // is only assigned in handleResize() method.
! Insets insets = getInsets(_insets);

// Set the preferred size of the component to the size of the
// image. The caller can adjust the actual size if desired.
***************
*** 850,863 ****

int w, h;
if (_imageOrigin == null) { // origin == min so they cancel
! w = _imageWidth + _insets.left + _insets.right;
! h = _imageHeight - _insets.top + _insets.bottom;
}
else {
w = _imageWidth - (_imageOrigin.x - _minX) +
! _insets.left + _insets.right;
h = _imageHeight - (_imageOrigin.y - _minY) +
! _insets.top + _insets.bottom;
}
_imageScreenWidth = w;
_imageScreenHeight = h;
--- 860,873 ----

int w, h;
if (_imageOrigin == null) { // origin == min so they cancel
! w = _imageWidth + insets.left + insets.right;
! h = _imageHeight - insets.top + insets.bottom;
}
else {
w = _imageWidth - (_imageOrigin.x - _minX) +
! insets.left + insets.right;
h = _imageHeight - (_imageOrigin.y - _minY) +
! insets.top + insets.bottom;
}
_imageScreenWidth = w;
_imageScreenHeight = h;
***************
*** 1239,1248 ****
{

if (_im == null) { // No image, just erase and return
! g.clearRect(0, 0, getWidth(), getHeight());
return;
}

// Get the clipping rectangle and translate it into image coordinates.
// This is the new damaged area.

--- 1249,1266 ----
{

if (_im == null) { // No image, just erase and return
! // Per Javadoc comment, we are using fillRect() and not
! // clearRect() to ensure that an offscreen image is
! // cleared to a specific color.
! g.setColor(this.getBackground());
! g.fillRect(0, 0, getWidth(), getHeight());
return;
}

+ // handleResize() will properly set _insets if needed.
+ if (_insets == null )
+ handleResize();
+
// Get the clipping rectangle and translate it into image coordinates.
// This is the new damaged area.

***************
*** 1511,1516 ****
--- 1529,1538 ----
if (g2d == null)
return null; // not currently visible

+ // handleResize() will properly set _insets if needed.
+ if (_insets == null )
+ handleResize();
+
// Intersect the tile and visible bounds first to get the smallest
// possible area

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sportinguista
Offline
Joined: 2010-05-30

Humm... I´m interested in getting this patch for Windows enviroment, where could I find the installer?

Bob Deen

I don't know, I don't use Windows. But the patches are not very
extensive and you should be able to apply the diffs by hand if necessary.

-Bob

jai-interest@javadesktop.org wrote:
> Humm... I´m interested in getting this patch for Windows enviroment, where could I find the installer?
> [Message sent by forum member 'sportinguista']
>
> http://forums.java.net/jive/thread.jspa?messageID=478221
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

pentath
Offline
Joined: 2009-08-04

If you will be working with software updates in the form of patches at all, do yourself a favor and find the actual patch utility. I can recommend Cygwin, since it comes with a fairly complete unix-like development environment, including the 'patch' command.