Example usage for java.awt Component getParent

List of usage examples for java.awt Component getParent

Introduction

In this page you can find the example usage for java.awt Component getParent.

Prototype

public Container getParent() 

Source Link

Document

Gets the parent of this component.

Usage

From source file:com.actelion.research.table.view.JVisualization.java

/**
 * @param rowID if != -1 then update this row only
 *//*w w  w. ja  va 2  s . co m*/
private void setSimilarityColors(int rowID) {
    if (mActivePoint == null) {
        for (int i = 0; i < mDataPoints; i++)
            mPoint[i].colorIndex = VisualizationColor.cDefaultDataColorIndex;
    } else {
        float min = Float.isNaN(mMarkerColor.getColorMin()) ? 0.0f : mMarkerColor.getColorMin();
        float max = Float.isNaN(mMarkerColor.getColorMax()) ? 1.0f : mMarkerColor.getColorMax();
        if (min >= max) {
            min = 0.0f;
            max = 1.0f;
        }

        int column = mMarkerColor.getColorColumn();
        float[] flexophoreSimilarity = null;
        if (rowID == -1 && DescriptorConstants.DESCRIPTOR_Flexophore.shortName
                .equals(mTableModel.getColumnSpecialType(column))) {
            // if we have the slow 3DPPMM2 then use a progress dialog and multi-threading
            Object descriptor = mActivePoint.record.getData(column);
            if (descriptor != null) {
                Component c = this;
                while (!(c instanceof Frame))
                    c = c.getParent();

                String idcode = new String(
                        (byte[]) mActivePoint.record.getData(mTableModel.getParentColumn(column)));
                flexophoreSimilarity = createSimilarityListSMP(idcode, descriptor, column);
                if (flexophoreSimilarity == null) { // cancelled
                    mMarkerColor.setColor(cColumnUnassigned);
                    return;
                }
            }
        }

        for (int i = 0; i < mDataPoints; i++) {
            if (rowID == -1 || mActivePoint.record.getID() == rowID) {
                float similarity = (flexophoreSimilarity != null) ? flexophoreSimilarity[i]
                        : mTableModel.getDescriptorSimilarity(mActivePoint.record, mPoint[i].record, column);
                if (Float.isNaN(similarity))
                    mPoint[i].colorIndex = VisualizationColor.cMissingDataColorIndex;
                else if (similarity <= min)
                    mPoint[i].colorIndex = (byte) VisualizationColor.cSpecialColorCount;
                else if (similarity >= max)
                    mPoint[i].colorIndex = (byte) (mMarkerColor.getColorList().length - 1);
                else
                    mPoint[i].colorIndex = (byte) (0.5 + VisualizationColor.cSpecialColorCount
                            + (float) (mMarkerColor.getColorList().length
                                    - VisualizationColor.cSpecialColorCount - 1) * (similarity - min)
                                    / (max - min));
            }
        }
    }
}

From source file:self.philbrown.javaQuery.$.java

/**
 * Interprets the CSS-style String and sets the value
 * @param view the view that will change.
 * @param key the name of the attribute/*from   w ww  . jav a2  s.c  o  m*/
 * @param _value the end animation value
 * @return the computed value
 */
private Object getAnimationValue(Component view, String key, String _value) {
    Object value = null;

    String[] split = (_value).split("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)");
    if (split.length == 1) {
        if (split[0].contains(".")) {
            value = Float.valueOf(split[0]);
        } else {
            value = Integer.valueOf(split[0]);
        }
    } else {
        if (split.length > 2) {
            Log.w("javaQuery", "parsererror for key " + key);
            return null;
        }
        if (split[1].equalsIgnoreCase("px")) {
            //this is the default. Just determine if float or int
            if (split[0].contains(".")) {
                value = Float.valueOf(split[0]);
            } else {
                value = Integer.valueOf(split[0]);
            }
        } else if (split[1].equalsIgnoreCase("dip") || split[1].equalsIgnoreCase("dp")
                || split[1].equalsIgnoreCase("sp")) {
            Log.w("$", "Dimension not supported");
            if (split[0].contains(".")) {
                value = Float.valueOf(split[0]);
            } else {
                value = Integer.valueOf(split[0]);
            }
        } else if (split[1].equalsIgnoreCase("in")) {
            float pt = view(0).getGraphics().getFontMetrics().getFont().deriveFont(1).getSize2D() / 72;
            if (split[0].contains(".")) {
                value = Float.parseFloat(split[0]) * pt;
            } else {
                value = Integer.parseInt(split[0]) * pt;
            }
        } else if (split[1].equalsIgnoreCase("mm")) {
            float pt = view(0).getGraphics().getFontMetrics().getFont().deriveFont(1).getSize2D() / 72;
            if (split[0].contains(".")) {
                value = Float.parseFloat(split[0]) * pt / 25.4;
            } else {
                value = Integer.parseInt(split[0]) * pt / 25.4;
            }
        } else if (split[1].equalsIgnoreCase("pt")) {
            if (split[0].contains(".")) {
                value = view(0).getGraphics().getFontMetrics().getFont().deriveFont(Float.parseFloat(split[0]))
                        .getSize2D();
            } else {
                value = view(0).getGraphics().getFontMetrics().getFont().deriveFont(Integer.parseInt(split[0]))
                        .getSize2D();
            }
        } else if (split[1].equals("%")) {
            Rectangle windowBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
            Component parent = view.getParent();
            float pixels = 0;
            if (parent == null) {
                pixels = windowBounds.width;
                //use best guess for width or height dpi
                if (split[0].equalsIgnoreCase("y") || split[0].equalsIgnoreCase("top")
                        || split[0].equalsIgnoreCase("bottom")) {
                    pixels = windowBounds.height;
                }
            } else {
                pixels = parent.getWidth();
                if (split[0].equalsIgnoreCase("y") || split[0].equalsIgnoreCase("top")
                        || split[0].equalsIgnoreCase("bottom")) {
                    pixels = parent.getHeight();
                }
            }
            float percent = 0;
            if (pixels != 0)
                percent = Float.valueOf(split[0]) / 100 * pixels;
            if (split[0].contains(".")) {
                value = percent;
            } else {
                value = (int) percent;
            }
        } else {
            Log.w("javaQuery", "invalid units for Object with key " + key);
            return null;
        }
    }
    return value;
}

From source file:edu.ku.brc.af.ui.forms.FormViewObj.java

/**
 * Adjust the Action and MenuItem for CarryForward.
 * @param isVisible whether is is visible
 *///from w ww  .j  a v a2 s . c o  m
private void adjustActionsAndMenus(final boolean isVisibleArg) {
    // Temporary fix for Bug 7231
    // A call to showView get put out on the event queue for other reasons
    // and with a closeAll happening that call to show comes after the
    // call to hide it. This is great, what needs to be fixed
    // is not putting the call to showView on the event thread.
    // the call is made in 'aboutToShow'
    boolean isVisible = isVisibleArg;
    if (isVisible) {
        Component p = mainComp.getParent();
        while (p != null && !(p instanceof SubPaneIFace)) {
            p = p.getParent();
        }
        // it isn't in the TabbedPane if the parent is null
        if (p != null && p instanceof SubPaneIFace && p.getParent() == null) {
            isVisible = false;
        }
    }
    // done with temporary fix

    boolean isConfiged = isCarryForwardConfgured() && isVisible;
    enableActionAndMenu("CarryForward", isConfiged, isConfiged);

    enableActionAndMenu("ConfigCarryForward", isVisible, null);

    boolean doAutoNum = isAutoNumberOn() && isEditing && isVisible;
    enableActionAndMenu(AUTO_NUM, isEditing && isVisible, doAutoNum);

    enableActionAndMenu("SaveAndNew", isVisible, null);
}