Package lcmc.common.domain

Examples of lcmc.common.domain.ColorText


    public ColorText[] getSubtextsForGraph(final Application.RunMode runMode) {
        final List<ColorText> texts = new ArrayList<ColorText>();
        if (getHost().isConnected()) {
            if (!getHost().isCrmStatusOk()) {
               texts.add(new ColorText("waiting for Pacemaker...", null, Color.BLACK));
            }
        } else {
            texts.add(new ColorText("connecting...", null, Color.BLACK));
        }
        return texts.toArray(new ColorText[texts.size()]);
    }
View Full Code Here


    /** Returns subtexts that appears in the service vertex. */
    @Override
    public ColorText[] getSubtextsForGraph(final Application.RunMode runMode) {
        final List<ColorText> texts = new ArrayList<ColorText>();
        ColorText prevColorText = null;

        for (final ServiceInfo child : getGroupServices()) {
            final ColorText[] colorTexts = child.getSubtextsForGraph(runMode);

            if (colorTexts == null || colorTexts.length == 0) {
                continue;
            }
            final ColorText sColorText = colorTexts[0];
            if (prevColorText == null || !sColorText.getSubtext().equals(prevColorText.getSubtext())) {
                texts.add(new ColorText(sColorText.getSubtext() + ':', sColorText.getColor(), Color.BLACK));
                prevColorText = sColorText;
            }
            String unmanaged = "";
            if (!child.isManaged(runMode)) {
                unmanaged = " / unmanaged";
            }
            String migrated = "";
            if (child.getMigratedTo(runMode) != null || child.getMigratedFrom(runMode) != null) {
                migrated = " / migrated";
            }
            final HbConnectionInfo[] hbcis = getBrowser().getCrmGraph().getHbConnections(child);
            String constraintLeft = "";
            String constraint = "";
            if (hbcis != null) {
                boolean scoreFirst = false;
                boolean scoreThen = false;
                boolean someConnection = false;
                for (final HbConnectionInfo hbci : hbcis) {
                    if (hbci == null) {
                        continue;
                    }
                    if (!someConnection && hbci.hasColocationOrOrder(child)) {
                        someConnection = true;
                    }
                    if (!scoreFirst && !hbci.isOrdScoreNull(child, null)) {
                        scoreFirst = true;
                    }
                    if (!scoreThen && !hbci.isOrdScoreNull(null, child)) {
                        scoreThen = true;
                    }
                }
                if (someConnection) {
                    if (scoreFirst || scoreThen) {
                        if (scoreFirst) {
                            constraint = " \u2192"; /* -> */
                        }
                        if (scoreThen) {
                            constraintLeft = "\u2192 "; /* -> */
                        }
                    } else {
                        /* just colocation */
                        constraint = " --"; /* -- */
                    }
                }
            }
            texts.add(new ColorText("   " + constraintLeft + child + unmanaged + migrated + constraint,
                                  sColorText.getColor(),
                                  Color.BLACK));
            boolean skip = true;
            for (final ColorText st : colorTexts) {
                if (skip) {
                    skip = false;
                    continue;
                }
                texts.add(new ColorText("   " + st.getSubtext(), st.getColor(), Color.BLACK));
            }
        }
        return texts.toArray(new ColorText[texts.size()]);
    }
View Full Code Here

                    s = s + " VG:" + drbdVG;
                } else {
                    s += " PV";
                }
            }
            return new ColorText(s, Color.BLUE, Color.BLACK);
        } else if (vg != null && !"".equals(vg)) {
            if (isLVM()) {
                return new ColorText("LV in " + vg, Color.BLUE, Color.GREEN);
            } else {
                return new ColorText(getName(), Color.BLUE, Color.GREEN);
            }
        } else if (getBlockDevice().isPhysicalVolume()) {
            return PHYSICAL_VOLUME_COLOR_TEXT;
        }
        return null;
View Full Code Here

                iconTextLayout = getVertexTextLayout(g2d, iconText, 0.8);
                iconTextWidth = (int) iconTextLayout.getBounds().getWidth();
            }

            /* right corner text */
            final ColorText rightCornerText = getRightCornerText((Vertex) v, getRunMode());
            TextLayout rightCornerTextLayout = null;
            if (rightCornerText != null && !"".equals(rightCornerText.getSubtext())) {
                rightCornerTextLayout = getVertexTextLayout(g2d, rightCornerText.getSubtext(), 0.8);
                final int rightCornerTextWidth = (int) rightCornerTextLayout.getBounds().getWidth();

                if (iconTextWidth + rightCornerTextWidth + 10 > shapeWidth) {
                    shapeWidth = iconTextWidth + rightCornerTextWidth + 10;
                }
            }

            /* subtext */
            final ColorText[] colorTexts = getSubtexts((Vertex) v, getRunMode());
            TextLayout[] subtextLayouts = null;
            if (colorTexts != null) {
                subtextLayouts = new TextLayout[colorTexts.length];
                int i = 0;
                for (final ColorText colorText : colorTexts) {
                    subtextLayouts[i] = getVertexTextLayout(g2d, colorText.getSubtext(), 0.8);
                    final int subtextWidth = (int) subtextLayouts[i].getBounds().getWidth();
                    if (subtextWidth + 10 > shapeWidth) {
                        shapeWidth = subtextWidth + 10;
                    }
                    i++;
                }
                if (i > 1) {
                    shapeHeight += (i - 1) << 3;
                }
                shapeHeight += 3;
            }
            final int oldShapeWidth = getVertexWidth((Vertex) v);
            final int oldShapeHeight = getVertexHeight((Vertex) v);
            if (isRunModeTestAnimation()) {
                if (oldShapeWidth > shapeWidth) {
                    shapeWidth = oldShapeWidth;
                }
                if (oldShapeHeight > shapeHeight) {
                    shapeHeight = oldShapeHeight;
                }
            }
            final boolean widthChanged = Math.abs(oldShapeWidth - shapeWidth) > 5;
            final boolean heightChanged = Math.abs(oldShapeHeight - shapeHeight) > 1;
            if (widthChanged || heightChanged) {
                somethingChanged();
                /* move it, so that left side has the same position, if it is
                * resized */
                final Point2D pos = layout.transform((Vertex) v);
                if (pos != null) {
                    double x = pos.getX();
                    double y = pos.getY();
                    if (widthChanged) {
                        setVertexWidth((Vertex) v, shapeWidth);
                        x -= (oldShapeWidth - getVertexWidth((Vertex) v)) / 2;
                    }
                    if (heightChanged) {
                        setVertexHeight((Vertex) v, shapeHeight);
                        y -= (oldShapeHeight - getVertexHeight((Vertex) v)) / 2;
                    }
                    pos.setLocation(x, y);
                    application.invokeLater(new Runnable() {
                                          @Override
                                          public void run() {
                                              scale();
                                          }
                                      });
                }
            }

            /* shape */
            super.paintShapeForVertex(rc, v, shape);
            Point2D loc = layout.transform((Vertex) v);
            loc = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, loc);
            final double x = loc.getX() - getVertexWidth((Vertex) v) / 2;
            final double height = getDefaultVertexHeight((Vertex) v);
            final double y = loc.getY() - getVertexHeight((Vertex) v) / 2;
            drawInside((Vertex) v, g2d, x, y, shape);

            /* icon */
            if (icons != null) {
                for (final ImageIcon icon : icons) {
                    icon.setDescription("");
                    g2d.drawImage(icon.getImage(),
                                  (int) (x + 4),
                                  (int) (y + height / 2 - icon.getIconHeight() / 2),
                                  null);
                }
            }

            /* texts are drawn from left down corner. */
            if (mainTextLayout != null) {
                final int textW = (int) mainTextLayout.getBounds().getWidth();
                final int textH = (int) mainTextLayout.getBounds().getHeight();
                drawVertexText(g2d,
                               mainTextLayout,
                               x + shapeWidth / 2 - textW / 2, /* middle */
                               y + height / 2 + textH / 2,
                               new Color(0, 0, 0),
                               255);
            }
            if (iconTextLayout != null) {
                drawVertexText(g2d, iconTextLayout, x + 4, y + 11, new Color(0, 0, 0), 255);
            }
            if (rightCornerTextLayout != null) {
                drawVertexText(g2d,
                               rightCornerTextLayout,
                               x + shapeWidth - rightCornerTextLayout.getBounds().getWidth() - 4,
                               y + 11,
                               rightCornerText.getTextColor(),
                               255);
            }
            if (subtextLayouts != null) {
                int i = 0;
                for (final TextLayout l : subtextLayouts) {
                    int alpha = 255;
                    final ColorText colorText = colorTexts[i];
                    if (" ".equals(colorText.getSubtext().substring(0, 1))) {
                        alpha = 128;
                    }
                    final Color color = colorText.getColor();
                    if (color != null) {
                        final Paint p =
                            new GradientPaint((float) x + shapeWidth / 2,
                                              (float) y,
                                              getVertexFillSecondaryColor((Vertex) v),
                                              (float) x + shapeWidth / 2,
                                              (float) y + shapeHeight,
                                              color,
                                              false);
                        g2d.setPaint(p);
                        g2d.fillRect((int) x + 4, (int) (y + height - 3 + 8 * (i - 1)), shapeWidth - 8, 9);
                    }
                    final Color textColor = colorText.getTextColor();
                    drawVertexText(g2d, l, x + 4, y + height - 4 + 8 * i, textColor, alpha);
                    i++;
                }
            }

View Full Code Here

                    || (proxyState != null && !BlockDevInfo.PROXY_UP.equals(proxyState))) {
                    color = Color.RED;
                    textColor = Color.WHITE;
                }
                return new ColorText[]{
                    new ColorText(Tools.join(" / ", new String[]{connState, diskState, diskStateOther, proxyState}),
                                color,
                                textColor)};
            }
        } else {
            final HostDrbdInfo hi = vertexToHostMap.get(v);
View Full Code Here

        final List<ColorText> texts = new ArrayList<ColorText>();
        final Map<String, String> notRunningOnNodes = new LinkedHashMap<String, String>();
        for (final Host h : getBrowser().getClusterHosts()) {
            notRunningOnNodes.put(h.getName().toLowerCase(Locale.US), h.getName());
        }
        texts.add(new ColorText(toString(), null, Color.BLACK));
        final ServiceInfo cs = getContainedService();
        if (cs != null && cs.getResourceAgent().isGroup()) {
            final ClusterStatus clStatus = getBrowser().getClusterStatus();
            final List<String> resources = clStatus.getGroupResources(cs.getHeartbeatId(runMode), runMode);
            if (resources != null) {
                for (final String hbId : resources) {
                    final ServiceInfo si = getBrowser().getServiceInfoFromCRMId(hbId);
                    if (si == null) {
                        texts.add(new ColorText("   unknown", null, Color.BLACK));
                    } else {
                        texts.add(new ColorText("   " + si, null, Color.BLACK));
                    }
                }
            }
        }
        if (getBrowser().allHostsWithoutClusterStatus()) {
            return texts.toArray(new ColorText[texts.size()]);
        }
        final List<String> runningOnNodes = getRunningOnNodes(runMode);
        if (runningOnNodes != null && !runningOnNodes.isEmpty()) {
            if (cs != null && cs.getResourceAgent().isLinbitDrbd()) {
                texts.add(new ColorText("primary on:", null, Color.BLACK));
            } else if (getService().isMaster()) {
                texts.add(new ColorText("master on:", null, Color.BLACK));
            } else {
                texts.add(new ColorText("running on:", null, Color.BLACK));
            }
            final List<Color> colors = getBrowser().getCluster().getHostColorsInGraphs(runningOnNodes);
            int i = 0;
            for (final String n : runningOnNodes) {
                final Color color;
                if (i < colors.size()) {
                    color = colors.get(i);
                } else {
                    color = Color.GRAY;
                }
                texts.add(new ColorText(ClusterBrowser.IDENT_4 + n
                                      + getPingCountString(n, runMode)
                                      + getFailCountString(n, runMode),
                                      color,
                                      Color.BLACK));
                notRunningOnNodes.remove(n.toLowerCase(Locale.US));
                i++;
            }
        }
        if (getService().isMaster()) {
            final List<String> slaveOnNodes = getSlaveOnNodes(runMode);
            if (slaveOnNodes != null && !slaveOnNodes.isEmpty()) {
                final List<Color> colors = getBrowser().getCluster().getHostColorsInGraphs(slaveOnNodes);
                if (cs != null && cs.getResourceAgent().isLinbitDrbd()) {
                    texts.add(new ColorText("secondary on:", null, Color.BLACK));
                } else {
                    texts.add(new ColorText("slave on:", null, Color.BLACK));
                }
                int i = 0;
                for (final String n : slaveOnNodes) {
                    final Color color;
                    if (i < colors.size()) {
                        color = colors.get(i);
                    } else {
                        color = Color.GRAY;
                    }
                    texts.add(new ColorText(ClusterBrowser.IDENT_4 + n
                                          + getFailCountString(n, runMode),
                                          color,
                                          Color.BLACK));
                    notRunningOnNodes.remove(n.toLowerCase(Locale.US));
                    i++;
                }
            }
        }
        if (!notRunningOnNodes.isEmpty()) {
            final Color nColor = ClusterBrowser.SERVICE_STOPPED_FILL_PAINT;
            if (isStopped(runMode)) {
                texts.add(new ColorText("stopped", nColor, Color.BLACK));
            } else {
                texts.add(new ColorText("not running on:", nColor, Color.BLACK));
                for (final Map.Entry<String, String> notRunningEntry : notRunningOnNodes.entrySet()) {
                    final String hostName = notRunningEntry.getValue();
                    Color color = nColor;
                    if (failedOnHost(hostName, runMode)) {
                        color = null;
                    }
                    texts.add(new ColorText(ClusterBrowser.IDENT_4
                                          + hostName
                                          + getFailCountString(hostName, runMode),
                                          color,
                                          Color.BLACK));
                }
View Full Code Here

    public ColorText[] getSubtextsForDrbdGraph(final Application.RunMode runMode) {
        final List<ColorText> texts = new ArrayList<ColorText>();
        if (getHost().isConnected()) {
            if (!getHost().isDrbdLoaded()) {
               texts.add(new ColorText("DRBD not loaded", null, Color.BLACK));
            } else if (!getHost().isDrbdStatusOk()) {
               texts.add(new ColorText("waiting...", null, Color.BLACK));
            }
        } else {
            texts.add(new ColorText("connecting...", null, Color.BLACK));
        }
        return texts.toArray(new ColorText[texts.size()]);
    }
View Full Code Here

        } else {
            textOn = Tools.getString("ServiceInfo.Filesystem.RunningOn");
            textNotOn = Tools.getString("ServiceInfo.Filesystem.NotRunning");
        }
        if (getService().isOrphaned()) {
            texts.add(new ColorText("...", null, Color.BLACK));
        } else if (getResource().isNew()) {
            texts.add(new ColorText(textNotOn + " (new)", ClusterBrowser.SERVICE_STOPPED_FILL_PAINT, Color.BLACK));
        } else if (isFailed(runMode)) {
            texts.add(new ColorText(textNotOn, null, Color.BLACK));
        } else if (isStopped(runMode) && !isRunning(runMode)) {
            texts.add(new ColorText("stopped", ClusterBrowser.SERVICE_STOPPED_FILL_PAINT, Color.BLACK));
        } else {
            Color textColor = Color.BLACK;
            String runningOnNodeString = null;
            Color color = null;
            if (getBrowser().allHostsWithoutClusterStatus()) {
                runningOnNodeString = "unknown";
            } else {
                final List<String> runningOnNodes = getRunningOnNodes(runMode);
                if (runningOnNodes != null && !runningOnNodes.isEmpty()) {
                    runningOnNodeString = runningOnNodes.get(0);
                    if (resourceAgent.isPingService()
                        && "0".equals(getPingCount(runningOnNodeString, runMode))) {
                        color = Color.RED;
                        textColor = Color.WHITE;
                    } else {
                        color = getBrowser().getCluster().getHostColorsInGraphs(runningOnNodes).get(0);
                    }
                }
            }
            if (runningOnNodeString == null) {
                texts.add(new ColorText(textNotOn, ClusterBrowser.SERVICE_STOPPED_FILL_PAINT, textColor));
            } else {
                texts.add(new ColorText(textOn + ": " + runningOnNodeString
                                      + getPingCountString(runningOnNodeString, runMode),
                                      color,
                                      textColor));
            }
        }
        if (isOneFailedCount(runMode)) {
            for (final Host host : getBrowser().getClusterHosts()) {
                if (host.isCrmStatusOk() && getFailCount(host.getName(), runMode) != null) {
                    texts.add(new ColorText(ClusterBrowser.IDENT_4
                                          + host.getName()
                                          + getFailCountString(host.getName(), runMode),
                                          null,
                                          Color.BLACK));
                }
View Full Code Here

TOP

Related Classes of lcmc.common.domain.ColorText

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.