Example usage for java.awt.geom Rectangle2D getX

List of usage examples for java.awt.geom Rectangle2D getX

Introduction

In this page you can find the example usage for java.awt.geom Rectangle2D getX.

Prototype

public abstract double getX();

Source Link

Document

Returns the X coordinate of the upper-left corner of the framing rectangle in double precision.

Usage

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Returns the data area for the chart (the area inside the axes) with the current scaling
 * applied (that is, the area as it appears on screen).
 * //w ww  .  j  a  v a 2s . co m
 * @return The scaled data area.
 */
public Rectangle2D getScreenDataArea() {
    Rectangle2D dataArea = this.info.getPlotInfo().getDataArea();
    Insets insets = getInsets();
    double x = dataArea.getX() * this.scaleX + insets.left;
    double y = dataArea.getY() * this.scaleY + insets.top;
    double w = dataArea.getWidth() * this.scaleX;
    double h = dataArea.getHeight() * this.scaleY;
    return new Rectangle2D.Double(x, y, w, h);
}

From source file:org.rdv.viz.chart.ChartPanel.java

/**
 * Applies any scaling that is in effect for the chart drawing to the
 * given rectangle.//w w  w .j av  a2  s. c o m
 *
 * @param rect  the rectangle (<code>null</code> not permitted).
 *
 * @return A new scaled rectangle.
 */
public Rectangle2D scale(Rectangle2D rect) {
    Insets insets = getInsets();
    double x = rect.getX() * getScaleX() + insets.left;
    double y = rect.getY() * getScaleY() + insets.top;
    double w = rect.getWidth() * getScaleX();
    double h = rect.getHeight() * getScaleY();
    return new Rectangle2D.Double(x, y, w, h);
}

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Zooms in on a selected region.//w ww .  jav a  2  s.  co  m
 * 
 * @param selection
 *            the selected region.
 */
public void zoom(Rectangle2D selection) {

    // get the origin of the zoom selection in the Java2D space used for
    // drawing the chart (that is, before any scaling to fit the panel)
    Point2D selectOrigin = translateScreenToJava2D(
            new Point((int) Math.ceil(selection.getX()), (int) Math.ceil(selection.getY())));
    PlotRenderingInfo plotInfo = this.info.getPlotInfo();
    Rectangle2D scaledDataArea = getScreenDataArea((int) selection.getCenterX(), (int) selection.getCenterY());
    if ((selection.getHeight() > 0) && (selection.getWidth() > 0)) {

        double hLower = (selection.getMinX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        double hUpper = (selection.getMaxX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        double vLower = (scaledDataArea.getMaxY() - selection.getMaxY()) / scaledDataArea.getHeight();
        double vUpper = (scaledDataArea.getMaxY() - selection.getMinY()) / scaledDataArea.getHeight();

        Plot p = this.chart.getPlot();
        if (p instanceof Zoomable) {
            Zoomable z = (Zoomable) p;
            if (z.getOrientation() == PlotOrientation.HORIZONTAL) {
                z.zoomDomainAxes(vLower, vUpper, plotInfo, selectOrigin);
                z.zoomRangeAxes(hLower, hUpper, plotInfo, selectOrigin);
            } else {
                z.zoomDomainAxes(hLower, hUpper, plotInfo, selectOrigin);
                z.zoomRangeAxes(vLower, vUpper, plotInfo, selectOrigin);
            }
        }
    }
}

From source file:org.tsho.dmc2.core.chart.DmcLyapunovPlot.java

public boolean renderArea(Graphics2D g2, Rectangle2D dataArea) {

    CoreStatusEvent statusEv = new CoreStatusEvent(this);
    g2.setPaint(paint);//from w  w w .j  a  v  a2s  . co m

    final double parHStep, parVStep;
    double parHLower = domainAxis.getRange().getLowerBound();
    double parHUpper = domainAxis.getRange().getUpperBound();
    double parVLower = rangeAxis.getRange().getLowerBound();
    double parVUpper = rangeAxis.getRange().getUpperBound();

    parHStep = Math.abs(parHUpper - parHLower) / dataArea.getWidth();
    parVStep = Math.abs(parVUpper - parVLower) / dataArea.getHeight();

    final BufferedImage image = new BufferedImage((int) dataArea.getWidth(), (int) dataArea.getHeight(),
            BufferedImage.TYPE_INT_RGB);
    WritableRaster raster = image.getRaster();
    DataBufferInt dataBuffer = (DataBufferInt) raster.getDataBuffer();
    int[] data = dataBuffer.getData();

    final double parHStart = parHLower + parHStep / 2;
    final double parVStart = parVUpper - parVStep / 2;

    for (int i = 0; i < (int) dataArea.getWidth(); i++) {
        for (int j = 0; j < (int) dataArea.getHeight(); j++) {

            parameters.put(firstParLabel, parHStart + i * parHStep);
            parameters.put(secondParLabel, parVStart - j * parVStep);

            double[] result;
            int color;

            try {
                result = Lua.evaluateLyapunovExponents(model, parameters, initialPoint, iterations);
            } catch (ModelException e) {
                String mess = "Exception while:\n" + dumpVariableDoubles(parameters)
                        + dumpVariableDoubles(initialPoint);
                throw new ModelException(mess, e);
            }

            if (result == null) {
                System.out.println("i: " + i + " j: " + j);
                System.out.println("par1: " + parHStart + i * parHStep);
                System.out.println("par2: " + parVStart + j * parVStep);
                g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1);
                statusEv.setStatusString("exception");
                statusEv.setType(CoreStatusEvent.STRING);
                notifyCoreStatusListeners(statusEv);
                return false;
            }

            // both zero
            if (Math.abs(result[0]) < epsilon && Math.abs(result[1]) < epsilon) {
                color = Color.black.getRGB();
            }
            // one zero one positive
            else if (Math.abs(result[0]) < epsilon && result[1] > 0
                    || Math.abs(result[1]) < epsilon && result[0] > 0) {
                color = Color.red.getRGB();
            }
            // one zero one negative
            else if (Math.abs(result[0]) < epsilon && result[1] < 0
                    || Math.abs(result[1]) < epsilon && result[0] < 0) {
                color = Color.blue.getRGB();
            }
            // one positive one negative
            else if (result[0] < 0 && result[1] > 0 || result[1] < 0 && result[0] > 0) {
                color = Color.green.getRGB();
            }
            // both positive
            else if (result[0] > 0 && result[1] > 0) {
                color = Color.orange.getRGB();
            }
            // both negative
            else if (result[0] < 0 && result[1] < 0) {
                color = Color.pink.getRGB();
            } else { // impossible
                color = Color.yellow.getRGB();
            }

            data[i + j * (int) dataArea.getWidth()] = color;

            if (stopped == true) {
                return false;
            }
            if (j == (int) dataArea.getHeight() - 1) {
                g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1);
                statusEv.setPercent(0);
                statusEv.setType(CoreStatusEvent.COUNT | CoreStatusEvent.PERCENT);
                notifyCoreStatusListeners(statusEv);
            }
        }
    }

    return true;
}

From source file:org.rdv.viz.chart.ChartPanel.java

/**
 * Zooms in on a selected region./*from  w  w w  . java 2 s.c  om*/
 *
 * @param selection  the selected region.
 */
public void zoom(Rectangle2D selection) {

    // get the origin of the zoom selection in the Java2D space used for
    // drawing the chart (that is, before any scaling to fit the panel)
    Point2D selectOrigin = translateScreenToJava2D(
            new Point((int) Math.ceil(selection.getX()), (int) Math.ceil(selection.getY())));
    PlotRenderingInfo plotInfo = this.info.getPlotInfo();
    Rectangle2D scaledDataArea = getScreenDataArea((int) selection.getCenterX(), (int) selection.getCenterY());
    if ((selection.getHeight() > 0) && (selection.getWidth() > 0)) {

        double hLower = (selection.getMinX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        double hUpper = (selection.getMaxX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        double vLower = (scaledDataArea.getMaxY() - selection.getMaxY()) / scaledDataArea.getHeight();
        double vUpper = (scaledDataArea.getMaxY() - selection.getMinY()) / scaledDataArea.getHeight();

        Plot p = this.chart.getPlot();
        if (p instanceof Zoomable) {
            // save previous ranges for use later when zooming out
            if (p instanceof XYPlot && rangeHistory.empty()) {
                XYPlot xyPlot = (XYPlot) p;
                rangeHistory.push(xyPlot.getDomainAxis().getRange());
                rangeHistory.push(xyPlot.getRangeAxis().getRange());
            }

            Zoomable z = (Zoomable) p;
            if (z.getOrientation() == PlotOrientation.HORIZONTAL) {
                z.zoomDomainAxes(vLower, vUpper, plotInfo, selectOrigin);
                z.zoomRangeAxes(hLower, hUpper, plotInfo, selectOrigin);
            } else {
                z.zoomDomainAxes(hLower, hUpper, plotInfo, selectOrigin);
                z.zoomRangeAxes(vLower, vUpper, plotInfo, selectOrigin);
            }

            // save current ranges for use later when zooming out
            if (p instanceof XYPlot) {
                XYPlot xyPlot = (XYPlot) p;
                rangeHistory.push(xyPlot.getDomainAxis().getRange());
                rangeHistory.push(xyPlot.getRangeAxis().getRange());
            }
        }

    }

}

From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

/**
 * Applies any scaling that is in effect for the chart drawing to the given rectangle.
 * //w w w  .j  a va 2  s. co  m
 * @param rect
 *            the rectangle (<code>null</code> not permitted).
 * 
 * @return A new scaled rectangle.
 */

@Override
public Rectangle2D scale(Rectangle2D rect) {
    Insets insets = getInsets();
    double x = rect.getX() * getScaleX() + insets.left;
    double y = rect.getY() * getScaleY() + insets.top;
    double w = rect.getWidth() * getScaleX();
    double h = rect.getHeight() * getScaleY();
    return new Rectangle2D.Double(x, y, w, h);
}

From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

/**
 * Returns the data area for the chart (the area inside the axes) with the current scaling
 * applied (that is, the area as it appears on screen).
 * //w w  w. j  a v a 2  s .co m
 * @return The scaled data area.
 */

@Override
public Rectangle2D getScreenDataArea() {
    Rectangle2D dataArea = this.info.getPlotInfo().getDataArea();
    Insets insets = getInsets();
    double x = dataArea.getX() * this.scaleX + insets.left;
    double y = dataArea.getY() * this.scaleY + insets.top;
    double w = dataArea.getWidth() * this.scaleX;
    double h = dataArea.getHeight() * this.scaleY;
    return new Rectangle2D.Double(x, y, w, h);
}

From source file:spinworld.gui.RadarPlot.java

/**
 * Draws the label for one axis./* w  w w .  j  a va 2s  .  co m*/
 *
 * @param g2  the graphics device.
 * @param plotArea  whole plot drawing area (e.g. including space for labels)
 * @param plotDrawingArea  the plot drawing area (just spanning of axis)
 * @param value  the value of the label (ignored).
 * @param cat  the category (zero-based index).
 * @param startAngle  the starting angle.
 * @param extent  the extent of the arc.
 */
protected void drawLabel(Graphics2D g2, Rectangle2D plotArea, Rectangle2D plotDrawingArea, double value,
        int cat, double startAngle, double extent) {
    FontRenderContext frc = g2.getFontRenderContext();

    String label = null;
    if (this.dataExtractOrder == TableOrder.BY_ROW) {
        // if series are in rows, then the categories are the column keys
        label = this.labelGenerator.generateColumnLabel(this.dataset, cat);
    } else {
        // if series are in columns, then the categories are the row keys
        label = this.labelGenerator.generateRowLabel(this.dataset, cat);
    }

    double angle = normalize(startAngle);

    Font font = getLabelFont();
    Point2D labelLocation;
    do {
        Rectangle2D labelBounds = font.getStringBounds(label, frc);
        LineMetrics lm = font.getLineMetrics(label, frc);
        double ascent = lm.getAscent();

        labelLocation = calculateLabelLocation(labelBounds, ascent, plotDrawingArea, startAngle);

        boolean leftOut = angle > 90 && angle < 270 && labelLocation.getX() < plotArea.getX();
        boolean rightOut = (angle < 90 || angle > 270)
                && labelLocation.getX() + labelBounds.getWidth() > plotArea.getX() + plotArea.getWidth();

        if (leftOut || rightOut) {
            font = font.deriveFont(font.getSize2D() - 1);
        } else {
            break;
        }
    } while (font.getSize() > 8);

    Composite saveComposite = g2.getComposite();

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
    g2.setPaint(getLabelPaint());
    g2.setFont(font);
    g2.drawString(label, (float) labelLocation.getX(), (float) labelLocation.getY());
    g2.setComposite(saveComposite);
}

From source file:knop.psfj.BeadImage.java

/**
 * Gets the bead preview./* w w  w  .  j  a  v a  2  s.  co m*/
 *
 * @param trials the trials
 * @return the bead preview
 */
public ImageProcessor getBeadPreview(int trials) {
    if (trials == 0) {
        return null;
    }
    if (preview == null) {
        try {
            System.out.println("generating new preview");

            preview = getMiddleImage();

            if (preview == null) {
                return new ShortProcessor(previewWidth, previewHeight);
            }

            preview = preview.convertToRGB();

            for (BeadFrame frame : getBeadFrameList()) {
                Rectangle2D r = frame.getBoundaries();

                if (frame.isValid() == true) {
                    preview.setColor(Color.green);
                } else {
                    preview.setColor(Color.yellow);
                }

                if (frame.isValid() == false) {
                    r = getEnlargedFrame((Rectangle) r, MathUtils.round(r.getWidth() / 2));
                }

                preview.drawRect(round(r.getX()), round(r.getY()), round(r.getWidth()), round(r.getHeight()));
                if (frame.getId() == null) {
                    continue;
                }

            }

            status = "Done.";
            progress = 100;

            notifyObservers(MSG_PREVIEW_UPDATED, "Done.", 100, null);
        } catch (Exception e) {
            trials--;
            getBeadPreview(trials);
        }
    }
    return preview;

}

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartUIComponent.java

/***********************************************************************************************
 * Create or refresh the Chart on a separate thread.
 * Only create or update if asked to do so via the generate flag.
 *
 * @param dao// w ww .  j av  a2 s.co m
 * @param generateflag
 * @param message
 */

private synchronized void doRefreshChart(final ObservatoryInstrumentDAOInterface dao,
        final boolean generateflag, final String message) {
    //final String SOURCE = "ChartUIComponent.refreshChart() ";
    final String SOURCE = message;
    final ChartUIComponentPlugin thisUI;
    final boolean boolDebug;

    boolDebug = true;
    //        boolDebug = LOADER_PROPERTIES.isMetadataDebug()
    //                    || LOADER_PROPERTIES.isChartDebug();

    // For use in inner classes
    thisUI = this;

    // Stop any existing SwingWorker
    if ((getHostInstrument() != null) && (dao != null)) {
        LOGGER.debug(boolDebug, SOURCE + "DAO [dao.classname=" + dao.getClass().getName()
                + "] [instrument.name=" + dao.getInstrumentName() + "] [generate.flag=" + generateflag + "]");

        LOGGER.debug(boolDebug, SOURCE + "SwingWorker.controlledStop()");
    }

    SwingWorker.disposeWorker(workerRefresh, true, SWING_WORKER_STOP_DELAY >> 1);

    // Fire off another thread to process the Chart
    workerRefresh = new SwingWorker(REGISTRY.getThreadGroup(), SOURCE + "SwingWorker [group="
            + REGISTRY.getThreadGroup().getName() + "] [thread=" + getChartName() + "]") {
        public Object construct() {
            LOGGER.debug(boolDebug, SOURCE
                    + "SwingWorker START -------------------------------------------------------------------------!");

            // The result of this Thread is a JFreeChart
            // which may have been produced in a long process...
            if ((!isStopping()) && (getHostInstrument() != null)
                    && (getHostInstrument().getInstrumentState().isOn())) {
                try {
                    final JFreeChart chart;
                    final Calendar calObservatory;

                    // Either find the Current Observatory calendar, or provide a default
                    calObservatory = ObservatoryInstrumentHelper
                            .getCurrentObservatoryCalendar(REGISTRY.getFramework(), dao, boolDebug);

                    //-----------------------------------------------------------------------------
                    // Debug the data we are trying to display

                    if (boolDebug) {
                        // Dump the (partial) contents of each Series in the composite XYdataset
                        ChartHelper.dumpXYDataset(boolDebug, calObservatory, getPrimaryXYDataset(), 4, SOURCE
                                + "Original unmodified Primary XYDataset before channel or domain selection");

                        if ((getSecondaryXYDatasets() != null) && (!getSecondaryXYDatasets().isEmpty())) {
                            for (int intDatasetIndex = 0; intDatasetIndex < getSecondaryXYDatasets()
                                    .size(); intDatasetIndex++) {
                                ChartHelper.dumpXYDataset(boolDebug, calObservatory,
                                        getSecondaryXYDatasets().get(intDatasetIndex), 4,
                                        SOURCE + "Original unmodified Secondary XYDataset [" + intDatasetIndex
                                                + "] before channel or domain selection");
                            }
                        } else {
                            LOGGER.debug(boolDebug,
                                    SOURCE + "There are no SecondaryXYDatasets associated with this Chart");
                        }
                    }

                    //-----------------------------------------------------------------------------
                    // Apply a ChartUI and its Metadata to the specified DAO

                    ChartHelper.associateChartUIWithDAO(thisUI, getMetadata(), dao);

                    //-----------------------------------------------------------------------------
                    // Create a new Channel Selector showing the channels of the Primary Dataset

                    if ((getChannelSelectorOccupant() != null)
                            && (getHostInstrument().getInstrumentState().isOn()) && (dao != null)
                            && (generateflag)) {
                        LOGGER.debug(boolDebug,
                                SOURCE + "SwingWorker --> ChannelSelector --> createOrUpdateSelectors()");

                        // The Channel Selector will be empty until an XYDataset is loaded
                        // Note that ChannelCount etc. must be set before calling createOrUpdateSelectors()
                        getChannelSelectorOccupant().setChannelCount(getChannelCount());
                        getChannelSelectorOccupant().setTemperatureChannel(hasTemperatureChannel());
                        getChannelSelectorOccupant().setMetadata(getMetadata());
                        getChannelSelectorOccupant().setUpdateType(getUpdateType());

                        // Force a rebuild of the Channel Selector only if necessary
                        getChannelSelectorOccupant().createOrUpdateSelectors(getDatasetType(),
                                getPrimaryXYDataset(), getSecondaryXYDatasets(), dao.isDatasetTypeChanged(),
                                dao.isChannelCountChanged(), dao.isMetadataChanged(), dao.isRawDataChanged(),
                                dao.isProcessedDataChanged(), isRefreshable(), isClickRefresh(), boolDebug);
                    } else {
                        // This debug ASSUMES the Instrument is not NULL
                        LOGGER.debug(boolDebug, SOURCE + "Unable to configure the Channel Selector UIComponent"
                                + "  [has.channelselector=" + (hasChannelSelector())
                                + "] [channelselector.notnull=" + (getChannelSelectorOccupant() != null)
                                + "] [isselectedinstrument="
                                + ObservatoryUIHelper.isSelectedInstrument(getHostInstrument())
                                + "] [isinstrument.on=" + getHostInstrument().getInstrumentState().isOn()
                                + "] [dao.notnull=" + (dao != null) + "] [generateflag=" + generateflag + "]");
                    }

                    //-----------------------------------------------------------------------------
                    // Force a rebuild of the DatasetDomain Control only if necessary

                    if ((hasDatasetDomainControl()) && (getDatasetDomainControlOccupant() != null)
                            && (getHostInstrument().getInstrumentState().isOn()) && (dao != null)
                            && (generateflag)) {
                        LOGGER.debug(boolDebug, SOURCE
                                + "SwingWorker --> DatasetDomainControl --> createOrUpdateDomainControl()");

                        // Note that ChannelCount etc. must be set before calling createOrUpdateDomainControl()
                        getDatasetDomainControlOccupant().setRawDataChannelCount(getChannelCount());
                        getDatasetDomainControlOccupant().setTemperatureChannel(hasTemperatureChannel());
                        getDatasetDomainControlOccupant().setMetadata(getMetadata());
                        getDatasetDomainControlOccupant().setUpdateType(getUpdateType());

                        getDatasetDomainControlOccupant().createOrUpdateDomainControl(getDatasetType(),
                                getPrimaryXYDataset(), getSecondaryXYDatasets(), dao.isDatasetTypeChanged(),
                                dao.isChannelCountChanged(), dao.isMetadataChanged(), dao.isRawDataChanged(),
                                dao.isProcessedDataChanged(), isRefreshable(), isClickRefresh(), boolDebug);
                    } else {
                        // This debug ASSUMES the Instrument is not NULL
                        LOGGER.debug(boolDebug, SOURCE
                                + "Unable to configure the DatasetDomainControl UIComponent"
                                + "  [has.domaincontrol=" + (hasDatasetDomainControl())
                                + "] [domaincontrol.notnull=" + (getDatasetDomainControlOccupant() != null)
                                + "] [isselectedinstrument="
                                + ObservatoryUIHelper.isSelectedInstrument(getHostInstrument())
                                + "] [isinstrument.on=" + getHostInstrument().getInstrumentState().isOn()
                                + "] [dao.notnull=" + (dao != null) + "] [generateflag=" + generateflag + "]");
                    }

                    // Do this anyway, because it doesn't affect the UI
                    updateSliderLocalValues();

                    //-----------------------------------------------------------------------------
                    // If the Chart does not exist, create it
                    // If the Chart structure has changed, recreate it using the new configuration
                    // If only the data have changed, update the existing JFreeChart
                    // and return NULL here, to avoid redrawing

                    LOGGER.debug(boolDebug, SOURCE + "SwingWorker --> createOrUpdateChart()");

                    // Use the Observatory ResourceKey
                    setDisplayLimit(
                            REGISTRY.getIntegerProperty(getHostInstrument().getHostAtom().getResourceKey()
                                    + ResourceKeys.KEY_DISPLAY_DATA_MAX));

                    // Only create or update if asked to do so
                    // This is the last step, so can reset the DAO changed status flags
                    chart = ChartHelper.createOrUpdateChart(getHostInstrument(), thisUI, dao, generateflag,
                            getDatasetType(), getPrimaryXYDataset(), getSecondaryXYDatasets(), getUpdateType(),
                            isRefreshable(), isClickRefresh(), getDisplayLimit(), getDatasetDomainStartPoint(),
                            getDatasetDomainEndPoint(), getChannelSelectorOccupant(), boolDebug);
                    return (chart);
                }

                catch (final Exception exception) {
                    LOGGER.debug(boolDebug, SOURCE + "SwingWorker Thread GENERIC EXCEPTION");
                    exception.printStackTrace();
                    return null;
                }
            } else {
                LOGGER.debug(boolDebug,
                        SOURCE + "SwingWorker Thread stopping, or the Instrument has been turned OFF...");
                return (null);
            }
        }

        // Return a JFreeChart or NULL, depending on the outcome of createOrUpdateChart()
        // If NULL, don't affect the ChartPanel contents
        public void finished() {
            MetadataHelper.showMetadataList(getMetadata(), SOURCE + "Chart Metadata on arrival at finished()",
                    boolDebug);

            // Update the Chart on the Event Dispatching Thread
            // Check thoroughly that there is some point to this update...
            if ((workerRefresh != null) && (workerRefresh.get() != null)
                    && (workerRefresh.get() instanceof JFreeChart) && (SwingUtilities.isEventDispatchThread())
                    && (!isStopping()) && (getHostInstrument() != null)
                    && (getHostInstrument().getInstrumentState().isOn())) {
                // See if we already have a ChartPanel to hold the new JFreeChart
                if (getChartPanel() != null) {
                    LOGGER.debug(boolDebug, SOURCE
                            + "finished() Apply the JFreeChart returned by get() to exisiting ChartPanel");

                    getChartPanel().setChart((JFreeChart) workerRefresh.get());
                } else {
                    // There is NO ChartPanel, so start again from scratch
                    LOGGER.debug(boolDebug, SOURCE
                            + "finished() Create a NEW ChartPanel and apply the JFreeChart returned by get()");

                    setChartPanel(ChartPanelFactory.createChartPanel((JFreeChart) workerRefresh.get()));
                }

                // NOTE: Chart applied to the specified DAO which was passed as a parameter
                LOGGER.debug(boolDebug, SOURCE + "finished() returned JFreeChart on a ChartPanel");

                getChartContainer().removeAll();
                getChartContainer().add(getChartPanel(), BorderLayout.CENTER);
                getChartPanel().getChart().fireChartChanged();
                getChartContainer().revalidate();
            } else {
                // We failed to return a JFreeChart for some reason

                if (getPrimaryXYDataset() == null) {
                    LOGGER.debug(boolDebug, SOURCE
                            + "finished() No JFreeChart returned, Dataset is NULL, show BlankUIComponent");

                    // Getting here with a NULL dataset should mean no Chart!
                    // ChartContainer is always NOT NULL
                    getChartContainer().removeAll();
                    getChartContainer().add(
                            new BlankUIComponent(MSG_WAITING_FOR_DATA, DEFAULT_COLOUR_CANVAS, COLOUR_INFO_TEXT),
                            BorderLayout.CENTER);
                    getChartContainer().revalidate();

                    // ToDo Consider setting DAO Chart and ChartPanel Chart to NULL?
                    //SOURCE + "finished() No JFreeChart returned, Dataset is NULL, set Chart to NULL if possible");

                    //                        if (getChartPanel() != null)
                    //                            {
                    //                            getChartPanel().setChart(null);
                    //                            }
                } else {
                    // We have some data, if we also have a Chart, just display it again
                    if ((getChartPanel() != null) && (getChartPanel().getChart() != null)) {
                        LOGGER.debug(boolDebug, SOURCE
                                + "finished() No JFreeChart returned, Dataset is NOT NULL, redraw data on existing ChartPanel");

                        getChartContainer().removeAll();
                        getChartContainer().add(getChartPanel(), BorderLayout.CENTER);
                        getChartPanel().getChart().fireChartChanged();
                        getChartContainer().revalidate();
                    } else {
                        LOGGER.error(SOURCE
                                + "finished() No JFreeChart returned, Dataset is NOT NULL, but no Chart for display, no action taken");
                    }
                }
            }

            // Handle the DatasetDomainControl

            if ((getChartPanel() != null) && (hasDatasetDomainControl())
                    && (getDatasetDomainControlOccupant() != null)
                    && (getDatasetDomainControlOccupant().getDatasetDomainContainer() != null)) {
                final ChartRenderingInfo infoChart;
                final PlotRenderingInfo infoPlot;
                final Rectangle2D rectPlot;
                final Rectangle2D rectData;

                infoChart = getChartPanel().getChartRenderingInfo();
                infoPlot = infoChart.getPlotInfo();
                rectPlot = infoPlot.getPlotArea();
                rectData = infoPlot.getDataArea();

                // Trap the cases where the Plot hasn't been rendered, or there's nothing to lay out,
                // in which cases use the default sizes
                if ((rectPlot != null) && (rectData != null) && ((int) rectData.getWidth() > 0)
                        && ((int) rectData.getHeight() > 0) && ((int) rectData.getX() > 0)
                        && ((int) rectData.getY() > 0)) {
                    int intLeft;
                    int intRight;

                    // Try to get the slider to align with the extents of the data area
                    // Ideally this should happen also after WindowResizing events
                    intLeft = (int) rectData.getX();
                    intRight = (int) (getChartPanel().getWidth() - rectData.getWidth() - rectData.getX());

                    LOGGER.debug(boolDebug,
                            "DatasetDomainControl -- PANEL, PLOT & DATA AREAS" + "  [panel.width="
                                    + getChartPanel().getWidth() + "] [panel.height="
                                    + getChartPanel().getHeight() + "] [plot.width=" + rectPlot.getWidth()
                                    + "] [plot.height=" + rectPlot.getHeight() + "] [plot.x=" + rectPlot.getX()
                                    + "] [plot.y=" + rectPlot.getY() + "] [data.width=" + rectData.getWidth()
                                    + "] [data.height=" + rectData.getHeight() + "] [data.x=" + rectData.getX()
                                    + "] [data.y=" + rectData.getY() + "] [indent.left=" + intLeft
                                    + "] [indent.right=" + intRight + "]");

                    if (intLeft < 0) {
                        intLeft = 0;
                    }

                    if (intRight < 0) {
                        intRight = 0;
                    }

                    if ((intLeft + rectData.getWidth() + intRight) > getChartPanel().getWidth()) {
                        intRight = 5;
                    }

                    getDatasetDomainControlOccupant().getDatasetDomainContainer()
                            .setBorder(BorderFactory.createEmptyBorder(0, intLeft, 5, intRight));
                } else {
                    getDatasetDomainControlOccupant().getDatasetDomainContainer()
                            .setBorder(BorderFactory.createEmptyBorder(0, INDENT_LEFT, 5, INDENT_RIGHT));
                }

                // Layout the Domain slider control again
                getDatasetDomainControlOccupant().getDatasetDomainContainer().revalidate();
            }

            LOGGER.debug(boolDebug, SOURCE
                    + "SwingWorker.finished() STOP ---------------------------------------------------------------!\n");
        }
    };

    // Start the Thread we have prepared...
    workerRefresh.start();
}