Example usage for java.awt Color getBlue

List of usage examples for java.awt Color getBlue

Introduction

In this page you can find the example usage for java.awt Color getBlue.

Prototype

public int getBlue() 

Source Link

Document

Returns the blue component in the range 0-255 in the default sRGB space.

Usage

From source file:org.n52.server.sos.render.DiagramRenderer.java

/**
 * Builds up a DesignDescriptionList which stores the information
 * about the style of each timeseries./*from w w  w .  ja v  a 2s. co  m*/
 * 
 * @param options
 *            the options
 * @return the design description list
 */
private DesignDescriptionList buildUpDesignDescriptionList(DesignOptions options) {

    String domainAxisLabel;
    if (options.getLanguage() != null && options.getLanguage().equals("de")) {
        domainAxisLabel = "Zeit";
    } else { // default => "en"
        domainAxisLabel = "Time";
    }
    if (this.isOverview) {
        domainAxisLabel = null;
    }

    DesignDescriptionList designDescriptions = new DesignDescriptionList(domainAxisLabel);
    String observedPropertyWithGrid = options.getProperties().get(0).getPhenomenon();

    for (TimeseriesProperties tsProperties : options.getProperties()) {
        Color c = JavaHelper.transformToColor(tsProperties.getHexColor());
        String phenomenonId = tsProperties.getPhenomenon();
        String procedureId = tsProperties.getProcedure();
        String featureId = tsProperties.getFeature();
        boolean drawGrid = observedPropertyWithGrid.equals(phenomenonId);

        TimeseriesParametersLookup lookup = getParameterLookup(tsProperties);
        Feature feature = lookup.getFeature(featureId);
        Procedure procedure = lookup.getProcedure(procedureId);
        Phenomenon phenomenon = lookup.getPhenomenon(phenomenonId);

        designDescriptions.add(phenomenon, procedure, feature, tsProperties,
                new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) tsProperties.getOpacity() * 255 / 100),
                tsProperties.getLineStyle(), tsProperties.getLineWidth(), drawGrid);
    }
    return designDescriptions;
}

From source file:pl.edu.icm.visnow.lib.utils.ImageUtilities.java

public static BufferedImage transparentColor(BufferedImage src, Color trColor) {
    int w = src.getWidth();
    int h = src.getHeight();
    BufferedImage dst = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    if (src.getRaster().getNumBands() < 3) {
        for (int i = 0; i < 3; i++) {
            dst.getRaster().setSamples(0, 0, w, h, i, src.getRaster().getSamples(0, 0, w, h, 0, (int[]) null));
        }/*from  ww  w  . j av a2s. co m*/
    } else if (src.getRaster().getNumBands() >= 3) {
        for (int i = 0; i < 3; i++) {
            dst.getRaster().setSamples(0, 0, w, h, i, src.getRaster().getSamples(0, 0, w, h, i, (int[]) null));
        }
    }

    for (int x = 0; x < w; x++) {
        for (int y = 0; y < h; y++) {
            if (dst.getRaster().getSample(x, y, 0) == trColor.getRed()
                    && dst.getRaster().getSample(x, y, 1) == trColor.getGreen()
                    && dst.getRaster().getSample(x, y, 2) == trColor.getBlue()) {
                dst.getRaster().setSample(x, y, 3, 0);
            } else {
                dst.getRaster().setSample(x, y, 3, 255);
            }
        }
    }
    return dst;
}

From source file:umontreal.iro.lecuyer.charts.XYListSeriesCollection.java

public String toLatex(double XScale, double YScale, double XShift, double YShift, double xmin, double xmax,
        double ymin, double ymax) {

    // Calcule les bornes reelles du graphique, en prenant en compte la position des axes
    xmin = Math.min(XShift, xmin);
    xmax = Math.max(XShift, xmax);
    ymin = Math.min(YShift, ymin);
    ymax = Math.max(YShift, ymax);

    Formatter formatter = new Formatter(Locale.US);
    XYSeriesCollection tempSeriesCollection = (XYSeriesCollection) seriesCollection;
    double XEPSILON = (1.0E-4 / XScale) + XShift;
    double YEPSILON = (1.0E-4 / YScale) + YShift;
    boolean outOfBounds = false;
    MathFunction[] spline = null;/*from ww w  .ja  v  a  2 s. c  om*/
    double[] xBounds = getRangeBounds();
    double[] yBounds = getDomainBounds();
    double x, y;
    // Smoothing splines, consulter  ref: QA278.2 G74, QA278.2 T35, QA278.2 E87

    //       if(xBounds[0] < xmin || xBounds[1] > xmax || yBounds[0] < ymin || yBounds[1] > ymax) {
    //          // on sait qu'il y a des points qui vont sortir du chart
    //          // initialisation d'une spline pour chaque courbe
    //          spline = new SmoothingCubicSpline[seriesCollection.getSeriesCount()];
    //          for(int i = 0; i<seriesCollection.getSeriesCount(); i++)
    //             spline[i] = new SmoothingCubicSpline(  (seriesCollection.getSeries(i).toArray())[0],
    //                                                    (seriesCollection.getSeries(i).toArray())[1], 0.5);
    //       }

    // on sait qu'il y a des points qui vont sortir du chart
    // initialisation d'une spline pour chaque courbe
    if (true) {
        spline = new SmoothingCubicSpline[tempSeriesCollection.getSeriesCount()];
        for (int i = 0; i < tempSeriesCollection.getSeriesCount(); i++)
            spline[i] = new SmoothingCubicSpline((tempSeriesCollection.getSeries(i).toArray())[0],
                    (tempSeriesCollection.getSeries(i).toArray())[1], 1);
    } else {
        spline = new AffineFit[tempSeriesCollection.getSeriesCount()];
        for (int i = 0; i < tempSeriesCollection.getSeriesCount(); i++)
            spline[i] = new AffineFit((tempSeriesCollection.getSeries(i).toArray())[0],
                    (tempSeriesCollection.getSeries(i).toArray())[1]);
    }

    for (int i = tempSeriesCollection.getSeriesCount() - 1; i >= 0; i--) {
        XYSeries temp = tempSeriesCollection.getSeries(i);

        if (temp.getItemCount() < 2)
            throw new IllegalArgumentException(
                    "Unable to plot series " + i + ": this series must have two points at least");

        Color color = (Color) renderer.getSeriesPaint(i);
        String colorString = detectXColorClassic(color);
        if (colorString == null) {
            colorString = "color" + i;
            formatter.format("\\definecolor{%s}{rgb}{%.2f, %.2f, %.2f}%n", colorString, color.getRed() / 255.0,
                    color.getGreen() / 255.0, color.getBlue() / 255.0);
        }

        // Cas particulier pour le premier point, on doit savoir si il est dans le chart ou pas
        if (temp.getX(0).doubleValue() >= xmin && temp.getX(0).doubleValue() <= xmax
                && temp.getY(0).doubleValue() >= ymin && temp.getY(0).doubleValue() <= ymax) {
            outOfBounds = false;
            formatter.format("\\draw [%s, color=%s, mark=%s, style=%s] plot coordinates {%%%n", plotStyle[i],
                    colorString, marksType[i], dashPattern[i]);
        } else {
            outOfBounds = true;
            formatter.format("%% ");
        }
        formatter.format("(%.2f,%.4f)", (temp.getX(0).doubleValue() - XShift) * XScale,
                (temp.getY(0).doubleValue() - YShift) * YScale);
        formatter.format(" %%   (%f,  %f)%n", temp.getX(0).doubleValue(), temp.getY(0).doubleValue());

        // Cas general
        for (int j = 1; j < temp.getItemCount(); j++) {
            double[] result;
            if (!outOfBounds) { //on est dans le chart
                result = evalLimitValues(xmin, xmax, ymin, ymax, XEPSILON, YEPSILON, spline[i], temp, j, false);
                // on regarde si on ne sort pas du chart, si c'est le cas on evalue le point en limite
                if (result != null) { // le point courant n'est pas dans le chart, on sort donc du chart
                    outOfBounds = true;
                    if (autoCompletion)
                        formatter.format("(%.2f,%.4f) %%%n", (result[0] - XShift) * XScale,
                                (result[1] - YShift) * YScale);
                    formatter.format("}%%%n%% ");
                }
            } else { // le point precedent etait hors du chart
                if (temp.getX(j).doubleValue() >= xmin && temp.getX(j).doubleValue() <= xmax
                        && temp.getY(j).doubleValue() >= ymin && temp.getY(j).doubleValue() <= ymax) {
                    // on rentre dans le chart, il faut evaluer le point en limite
                    j = j - 1;
                    result = evalLimitValues(xmin, xmax, ymin, ymax, XEPSILON, YEPSILON, spline[i], temp, j,
                            true);
                    // ici result ne peut pas etre null
                    formatter.format(";%%%n\\draw [%s, color=%s, mark=%s, style=%s] plot coordinates {%%%n",
                            plotStyle[i], colorString, marksType[i], dashPattern[i]);
                    if (autoCompletion)
                        formatter.format("(%.2f,%.4f) %%%n ", (result[0] - XShift) * XScale,
                                (result[1] - YShift) * YScale);
                    formatter.format("%% ");
                    outOfBounds = false;
                } else {
                    formatter.format("%% ");
                    // on les donnees sont toujours hors du chart
                }
            }
            /* on affiche les coordonnees du point quoiqu'il arrive,
            si celui ci est hors du chart alors la balise de commentaire a ete deja place */
            formatter.format("(%.2f,%.4f)", (temp.getX(j).doubleValue() - XShift) * XScale,
                    (temp.getY(j).doubleValue() - YShift) * YScale);
            if (j == temp.getItemCount() - 1)
                formatter.format("}");
            formatter.format(" %%   (%f,  %f)%n", temp.getX(j).doubleValue(), temp.getY(j).doubleValue());
            //            formatter.format(" %%%n");
        }
        formatter.format(" node[right] {%s};%n", (String) temp.getKey());
    }
    return formatter.toString();
}

From source file:at.tuwien.ifs.somtoolbox.apps.viewer.fileutils.ExportUtils.java

public void saveImageMap(GrowingLayer layer, int unitWidth, String fullPath, String baseFileName,
        String[][] visualisations, boolean isAudioSOM, SOMLibClassInformation classInfo, Color[] colors,
        Properties cleanDataNamesMapping, String inputDataFilesPrefix, String outputDataFilesPrefix,
        String htmlTemplatesDir, String imageMapTitle, boolean generateRhythmPatterns,
        boolean forceLinkGeneration) throws SOMToolboxException {

    String XHTML_FRAMESET = "";
    String XHTML_FRAMESET_INDEXFRAME = "";
    String XHTML_FRAMESET_UNITDETAILS = "";
    String IMAGE_MAP_PAGE = "";
    String UNIT_DETAIL_PAGE = "";
    String VISNAV_PAGE = "";

    String absolutePath = new File((fullPath + "x").substring(0, (fullPath + "x").lastIndexOf(File.separator)))
            .getAbsolutePath();//w w  w.j  a v a2 s .  c  om

    String detailsDir = fullPath + "_details/";
    String detailsDirRelative = baseFileName + "_details/";
    new File(detailsDir).mkdirs();

    String playlistDir = fullPath + "_playlist/";
    String playlistDirRelative = baseFileName + "_playlist/";
    if (isAudioSOM) {
        new File(playlistDir).mkdir();
    }

    String imageMapDir = fullPath + "_map/";
    String imageMapBaseName = baseFileName + "_map/";
    new File(imageMapDir).mkdir();

    String imageDir = fullPath + "_map/"; // if changed here, must be changed in ExportDialog.java as well
    String imageDirRelative = "../" + baseFileName + "_map/";
    new File(imageDir).mkdir();

    // We currently don't use fileTpye icons for generic files
    // (may be later introduced for images, videos, etc.)
    String iconFileType = ""; // = "file.png";
    String unitDetailsTarget = "unitDetails";
    if (isAudioSOM) {
        iconFileType = "note.png";
        unitDetailsTarget = "unitDetailsIndex";
    }

    // copy icons
    // copyResource(imageDir, RESOURCE_PATH_ICONS, iconFileType);
    if (isAudioSOM) {
        FileUtils.copyResource(imageDir, RESOURCE_PATH_ICONS, "play.png");
        FileUtils.copyResource(imageDir, RESOURCE_PATH_ICONS, "download.gif");
        FileUtils.copyResource(detailsDir, RESOURCE_PATH_ICONS, "rp_horizontal_scale.gif");
        FileUtils.copyResource(detailsDir, RESOURCE_PATH_ICONS, "rp_vertical_scale.gif");
    }

    // copy HTML style sheets & templates
    if (htmlTemplatesDir == null) {
        htmlTemplatesDir = ExportUtils.class.getResource(RESOURCE_PATH_CSS).getFile();// + RESOURCE_PATH_CSS;
    }
    if (!htmlTemplatesDir.endsWith(File.separator)) {
        htmlTemplatesDir += File.separator;
    }
    FileUtils.copyFileSafe(imageMapDir + "style.css", htmlTemplatesDir + "style.css");
    FileUtils.copyFileSafe(detailsDir + "styleUnitDetails.css", htmlTemplatesDir + "styleUnitDetails.css");
    FileUtils.copyResource(detailsDir, RESOURCE_PATH_XHTML, "UnitDetails_empty.html");

    try {
        XHTML_FRAMESET = FileUtils.readFromFile(RESOURCE_PATH_XHTML, "Frameset.html");
        XHTML_FRAMESET_INDEXFRAME = FileUtils.readFromFile(RESOURCE_PATH_XHTML, "IndexFrame.html");
        XHTML_FRAMESET_UNITDETAILS = FileUtils.readFromFile(RESOURCE_PATH_XHTML,
                "UnitDetailsContentFrame.html");
        IMAGE_MAP_PAGE = FileUtils.readFromFile(RESOURCE_PATH_XHTML, "ImageMap.html");
        VISNAV_PAGE = FileUtils.readFromFile(RESOURCE_PATH_XHTML, "VisualisationSelection.html");
        if (isAudioSOM && generateRhythmPatterns) {
            UNIT_DETAIL_PAGE = FileUtils.readFromFile(RESOURCE_PATH_XHTML, "UnitDetailsRhythmPattern.html");
        } else {
            UNIT_DETAIL_PAGE = FileUtils.readFromFile(RESOURCE_PATH_XHTML, "UnitDetails.html");
        }

        StringBuffer classLegend = new StringBuffer();
        if (classInfo != null) {
            classLegend.append("      <h3>Class Legend</h3>");
            classLegend.append("      <table>\n");
            String[] classNames = classInfo.classNames();
            for (int i = 0; i < classNames.length; i++) {
                if (i % 2 == 0) {
                    classLegend.append("        <tr>\n");
                }
                classLegend.append("          <td class=\"classLegend\" width=\"50%\">\n");
                classLegend.append("            <span style=\"background-color: rgb(" + colors[i].getRed() + ","
                        + colors[i].getGreen() + "," + colors[i].getBlue()
                        + ")\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;"
                        + StringUtils.beautifyForHTML(classNames[i]) + "\n");
                classLegend.append("          </td>\n");
                if (i % 2 == 1 || i + 1 == classNames.length) {
                    classLegend.append("        </tr>\n");
                }
            }
            classLegend.append("      </table>\n");
        }

        XHTML_FRAMESET_INDEXFRAME = XHTML_FRAMESET_INDEXFRAME
                .replaceAll("PLACEHOLDER_MAPINDEX", imageMapBaseName + "mapIndex.html")
                .replaceAll("PLACEHOLDER_TITLE", imageMapTitle);
        if (!isAudioSOM) { // we have a content frame on the right side
            XHTML_FRAMESET_INDEXFRAME = XHTML_FRAMESET_INDEXFRAME.replaceAll("PLACEHOLDER_DETAIL_FILE",
                    imageMapBaseName + "unitDetailsContentFrame.html");
        }

        // the visualisation links
        if (visualisations != null && visualisations.length > 0) {
            ArrayList<String[]> realVis = new ArrayList<String[]>();
            StringBuffer mapNavigation = new StringBuffer();
            for (String[] visualisation : visualisations) {
                if (visualisation[0].equals("SPACER")) {
                    mapNavigation.append("  " + visualisation[1] + "\n");
                } else {
                    mapNavigation.append("  <a href=\"" + visualisation[0] + ".html"
                            + "\" target=\"map\" class=\"visualisationLink\" id=\"" + visualisation[0]
                            + "\" name=\"visLink\" onclick=\"javascript:selectVis('" + visualisation[0]
                            + "')\">" + visualisation[1] + "</a>\n");
                    realVis.add(visualisation);
                }
            }
            visualisations = new String[realVis.size()][2];
            for (int i = 0; i < visualisations.length; i++) {
                visualisations[i] = realVis.get(i);
            }
            FileUtils.writeFile(imageMapDir + "mapNavigation.html",
                    VISNAV_PAGE.replaceAll("PLACE_HOLDER_VISUALISATION_LINKS", mapNavigation.toString())
                            .replaceAll("PLACE_HOLDER_DEFAULT_VIS",
                                    visualisations[visualisations.length - 1][0]));

            // the main frameset index, dividing into map & navigtation frame and details frame
            StringBuffer map = new StringBuffer();
            map.append("<frame src=\"" + visualisations[visualisations.length - 1][0]
                    + ".html\" name=\"map\" noresize=\"noresize\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" />\n");
            map.append(
                    "<frame src=\"mapNavigation.html\" name=\"mapNavigation\" noresize=\"noresize\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" />\n");
            FileUtils.writeFile(imageMapDir + "mapIndex.html",
                    XHTML_FRAMESET.replaceAll("PLACEHOLDER_TITLE", imageMapTitle)
                            .replaceAll("PLACE_HOLDER_FRAME_LAYOUT", "rows=\"*, 32\"")
                            .replaceAll("PLACEHOLDER_FRAMES", map.toString()));
        }

        boolean firstUnit = true;
        boolean firstDataItem = true;

        StringBuffer imageMap = new StringBuffer();
        for (int x = 0; x < layer.getXSize(); x++) {
            for (int y = 0; y < layer.getYSize(); y++) {
                Unit unit = layer.getUnit(x, y);
                if (unit != null) {
                    if (firstUnit) {
                        firstUnit = false;
                        if (isAudioSOM) {
                            XHTML_FRAMESET_INDEXFRAME = XHTML_FRAMESET_INDEXFRAME
                                    .replaceAll("PLACEHOLDER_DETAIL_FILE",
                                            detailsDirRelative + "unit_" + x + "_" + y + ".html")
                                    .replaceAll("PLACEHOLDER_TITLE", imageMapTitle);
                        } else {
                            XHTML_FRAMESET_UNITDETAILS = XHTML_FRAMESET_UNITDETAILS.replaceAll(
                                    "PLACEHOLDER_SOURCE_UNITDETAILS",
                                    "../" + detailsDirRelative + "unit_" + x + "_" + y + ".html");
                        }
                    }
                    String coordinates = x * unitWidth + "," + y * unitWidth + " " + (x + 1) * unitWidth + ","
                            + (y + 1) * unitWidth;
                    String[] mappedData = unit.getMappedInputNames();
                    Label[] labels = unit.getLabels();
                    boolean hasLabels = !isAudioSOM && labels != null && labels.length > 0;
                    if (mappedData != null) {
                        imageMap.append("  <area shape=\"rect\" href=\"../" + detailsDirRelative + "unit_" + x
                                + "_" + y + ".html" + "\" target=\"" + unitDetailsTarget + "\"");
                        imageMap.append("coords=\"" + coordinates + "\" title=\"");

                        StringBuffer unitDetails = new StringBuffer();
                        String playListLink = "";
                        String playList = "";
                        for (int i = 0; i < mappedData.length; i++) {
                            String dataName = mappedData[i];

                            // in an audio SOM we don't have labels - we just use the data names as tooltip pop-up
                            if (!hasLabels) {
                                if (cleanDataNamesMapping != null) {
                                    dataName = cleanDataNamesMapping.getProperty(dataName, dataName);
                                } else {
                                    dataName = dataName.substring(dataName.lastIndexOf("/") + 1)
                                            .replaceAll(".mp3", "").replaceAll("_", " ");
                                }
                                imageMap.append(dataName);
                                if (i + 1 < mappedData.length) {
                                    imageMap.append(DATA_ITEM_SEPERATOR);
                                }
                            }

                            if (classInfo != null) {
                                int classNr = classInfo.getClassIndex(mappedData[i]);
                                if (classNr != -1) {
                                    Color c = colors[classNr];
                                    String dataItemDetails = "      <span title=\""
                                            + classInfo.classNames()[classNr]
                                            + "\" style=\"background-color: rgb(" + c.getRed() + ","
                                            + c.getGreen() + "," + c.getBlue()
                                            + ")\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;";
                                    unitDetails.append(dataItemDetails);
                                }
                            }

                            String filePath = inputDataFilesPrefix + File.separator + mappedData[i];
                            boolean haveFile = new File(filePath).exists();
                            // add iconFileType
                            // if (haveFile || forceLinkGeneration) {
                            // unitDetails.append("<img src=\"" + imageDirRelative + iconFileType +
                            // "\" height=\"12\" border=\"0\" />&nbsp;");
                            // }
                            unitDetails.append(dataName);
                            if (haveFile || forceLinkGeneration) {
                                if (isAudioSOM) { // generate playlist
                                    // add iconFileType
                                    unitDetails.append("<img src=\"" + imageDirRelative + iconFileType
                                            + "\" height=\"12\" border=\"0\" />&nbsp;");

                                    new File((playlistDir + mappedData[i]).substring(0,
                                            (playlistDir + mappedData[i]).lastIndexOf(File.separator)))
                                                    .mkdirs();

                                    String mediaLocation;
                                    if (outputDataFilesPrefix != null) {
                                        if (FileUtils.isURL(outputDataFilesPrefix)) {
                                            mediaLocation = outputDataFilesPrefix + File.separator
                                                    + StringUtils.URLencode(mappedData[i]);
                                        } else {
                                            mediaLocation = outputDataFilesPrefix + File.separator
                                                    + mappedData[i];
                                            // + playlistDirRelative + mappedData[i];
                                        }
                                    } else {
                                        mediaLocation = mappedData[i]
                                                .substring(mappedData[i].lastIndexOf(File.separator) + 1);
                                    }

                                    String playListName = mappedData[i].substring(0, mappedData[i].length() - 4)
                                            + ".m3u";
                                    FileWriter playlistFileOut = new FileWriter(playlistDir + playListName);

                                    playlistFileOut.write(mediaLocation + "\n");
                                    playList += mediaLocation + "\n";
                                    playlistFileOut.close();
                                    unitDetails.append("&nbsp;&nbsp; ");
                                    unitDetails.append("<a href=\"../" + playlistDirRelative + playListName
                                            + "\" title=\"Play as m3u stream\" target=\"_download\">[<img src=\""
                                            + imageDirRelative
                                            + "play.png\" height=\"12\" border=\"0\" >stream]</a>");
                                    unitDetails.append("&nbsp; ");
                                    unitDetails.append("<a href=\"" + mediaLocation
                                            + "\" title=\"Download as MP3\" target=\"_download\">[<img src=\""
                                            + imageDirRelative
                                            + "download.gif\" height=\"12\" border=\"0\" >mp3]</a>");
                                } else { // just add link to view content in browser
                                    unitDetails.append("&nbsp;&nbsp; ");
                                    String dataLink = outputDataFilesPrefix + File.separator + mappedData[i];
                                    if (new File(absolutePath + File.separator + dataLink + ".html").exists()) {
                                        dataLink += ".html";
                                    }
                                    unitDetails.append("<a href=\"../" + dataLink
                                            + "\" target=\"contentDetails\" title=\"View\">[");
                                    // add iconFileType
                                    // unitDetails.append("<img src=\"" + imageDirRelative + iconFileType +
                                    // "\" height=\"12\" border=\"0\" >");
                                    unitDetails.append("view]</a>");
                                    if (firstDataItem) {
                                        firstDataItem = false;
                                        XHTML_FRAMESET_UNITDETAILS = XHTML_FRAMESET_UNITDETAILS.replaceAll(
                                                "PLACEHOLDER_SOURCE_CONTENTFILE",
                                                detailsDirRelative + "UnitDetails_empty.html");
                                        // "../" + dataLink);
                                    }
                                }
                            }
                            unitDetails.append("\n      <br/>\n");
                        }
                        // we have a SOM with labels
                        if (hasLabels) {
                            for (int i = 0; i < labels.length; i++) {
                                imageMap.append(labels[i].getName());
                                if (i + 1 < labels.length) {
                                    imageMap.append(DATA_ITEM_SEPERATOR);
                                }
                            }
                        }
                        imageMap.append("\" />\n");

                        if (playList.trim().length() > 0) {
                            String playListName = "unit_" + x + "_" + y + ".m3u";
                            FileWriter playlistUnitFileOut = new FileWriter(playlistDir + playListName);
                            playlistUnitFileOut.write(playList);
                            playlistUnitFileOut.close();
                            playListLink = "<a href=\"../" + playlistDirRelative + playListName
                                    + "\" title=\"Play all songs on this unit\" target=\"_download\">[<img src=\""
                                    + imageDirRelative + "play.png\" height=\"12\" border=\"0\" >play all]</a>";
                        }

                        String unitDetail = UNIT_DETAIL_PAGE
                                .replaceAll("PLACEHOLDER_UNIT_DETAILS", unitDetails.toString())
                                .replaceAll("PLACEHOLDER_UNIT_ID", x + "/" + y)
                                .replaceAll("PLACEHOLDER_PLAYLIST", playListLink);
                        unitDetail = unitDetail.replaceAll("PLACEHOLDER_CLASS_LEGEND", classLegend.toString());
                        if (isAudioSOM) {
                            if (generateRhythmPatterns) {
                                unitDetail = unitDetail.replaceAll("PLACEHOLDER_RP_IMAGE",
                                        "rp_" + x + "_" + y + ".jpg");
                                // TODO be careful: RP dimensions hardcoded again!
                                FileUtils.saveImageToFile(detailsDir + "rp_" + x + "_" + y + ".jpg",
                                        new RhythmPattern(layer.getUnit(x, y).getWeightVector(), 60, 24)
                                                .getImage());
                            }
                        }
                        FileUtils.writeFile(detailsDir + "unit_" + x + "_" + y + ".html", unitDetail);
                    }
                }
            }
        }

        FileUtils.writeFile(fullPath + "_index.html", XHTML_FRAMESET_INDEXFRAME);

        if (imageMapTitle == null) {
            imageMapTitle = "";
        } else {
            imageMapTitle = "<h2>" + imageMapTitle + "</h2>";
        }
        String imageMapPage = IMAGE_MAP_PAGE.replaceAll("PLACEHOLDER_MAP_AREAS", imageMap.toString())
                .replaceAll("PLACEHOLDER_IMAGE_MAP_TITLE", imageMapTitle);
        for (int i = 0; i < visualisations.length; i++) {
            if (!visualisations[i][0].equals("SPACER")) {
                FileUtils.writeFile(imageMapDir + visualisations[i][0] + ".html",
                        imageMapPage
                                .replaceAll("PLACE_HOLDER_MAP_IMAGE",
                                        imageDirRelative + visualisations[i][0] + ".png")
                                .replaceAll("PLACEHOLDER_TITLE", "Play-SOM - " + visualisations[i][0]));
            }
        }
        if (!isAudioSOM) {
            // the unit details frame on the right side
            FileUtils.writeFile(imageMapDir + "unitDetailsContentFrame.html", XHTML_FRAMESET_UNITDETAILS);
        }
    } catch (FileNotFoundException e) {
        throw new SOMToolboxException(e.getMessage());
    } catch (IOException e) {
        throw new SOMToolboxException(e.getMessage());
    }
}

From source file:LightTest.java

protected void OnColor() {
    Color rgb = m_ColorChooser.showDialog(m_Panel, "Set Light Color", null);

    if (rgb != null) {
        m_Light.setColor(new Color3f((float) rgb.getRed() / 255f, (float) rgb.getGreen() / 255f,
                (float) rgb.getBlue() / 255f));
    }//from w w w  .ja v a2  s  . c om
}

From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.panel.Chromatogram1DHeatmapViewerPanel.java

@Override
public void setPaintScale(PaintScale ps) {
    Logger.getLogger(getClass().getName()).info("Set paint scale called on HeatmapPanel");
    //        if (ps != null && ps instanceof GradientPaintScale) {
    Logger.getLogger(getClass().getName()).info("Paint scale using!");
    GradientPaintScale sps = (GradientPaintScale) ps;
    if (this.ps != null) {
        double lb = this.ps.getLowerBound();
        double ub = this.ps.getUpperBound();
        sps.setLowerBound(lb);//w w  w . j a v a2s.c om
        sps.setUpperBound(ub);
        //this.jSlider1.setValue(0);
    }
    this.alpha = (int) sps.getAlpha();
    this.beta = (int) sps.getBeta();
    this.ps = sps;
    Color c = (Color) sps.getPaint(this.ps.getUpperBound());
    if (chartPanel != null) {
        JFreeChart jfc = chartPanel.getChart();
        if (jfc != null) {
            XYPlot plot = jfc.getXYPlot();
            if (!jCheckBox2.isSelected()) {
                Color bg = (Color) this.ps.getPaint(this.ps.getLowerBound());
                Logger.getLogger(getClass().getName()).log(Level.INFO, "Background color: {0}", bg);
                setBackgroundColor(bg);
            }
        }
    }
    selectionFill = new Color(c.getRed(), c.getBlue(), c.getGreen(), 192);
    selectionOutline = new Color(c.getRed(), c.getBlue(), c.getGreen()).darker();
    this.jSlider1.setMaximum(100);
    this.jSlider1.setMinimum(0);
    handleSliderChange();
    //        }
}

From source file:com.jcraft.weirdx.XColormap.java

static void reqAllocNamedColor(Client c) throws IOException {
    int foo;/*from w ww  .j  av  a 2 s.  c om*/
    int n;
    int len;
    InputOutput io = c.client;
    n = c.length;
    foo = io.readInt();
    XColormap cmap = (XColormap) XResource.lookupIDByType(foo, XResource.RT_COLORMAP);
    c.length -= 2;
    if (cmap == null) {
        c.errorValue = foo;
        c.errorReason = 12; // Colormap
        return;
    }
    len = io.readShort();
    io.readPad(2);
    n = n - 3;
    n *= 4;
    n -= len;
    io.readByte(c.bbuffer, 0, len);
    io.readPad(n);
    c.length = 0;
    len = chopspace(c.bbuffer, len);
    if (len == 0) {
        c.errorReason = 2; // BadValue
        return;
    }

    String s = new String(c.bbuffer, 0, len);
    Color color = (Color) rgbTable.get(s);
    if (color != null) {

        int red = color.getRed();
        int green = color.getGreen();
        int blue = color.getBlue();

        int i = cmap.allocColor(c, color.getRed(), color.getGreen(), color.getBlue());
        if (c.errorReason != 0) {
            return;
        }

        if (cmap.visual.depth.depth != 16) {
            LocalEntry ent = (LocalEntry) cmap.entries[i];
            red = ent.r;
            green = ent.g;
            blue = ent.b;
            if (ent.refcnt == 1) {
                cmap.mkIcm();
            }
        }

        synchronized (io) {
            io.writeByte(1);
            io.writePad(1);
            io.writeShort(c.seq);
            io.writeInt(0);
            io.writeInt(i);
            io.writeShort(red | (red << 8));
            io.writeShort(green | (green << 8));
            io.writeShort(blue | (blue << 8));
            io.writeShort(red | (red << 8));
            io.writeShort(green | (green << 8));
            io.writeShort(blue | (blue << 8));
            io.writePad(8);
            io.flush();
            return;
        }
    }

    synchronized (io) {
        io.writeByte((byte) 0);
        io.writeByte((byte) 15);
        io.writeShort(c.seq);
        io.writePad(4);
        io.writeShort(0);
        io.writeByte((byte) 85);
        io.writePad(21);
        io.flush();
    }
}

From source file:com.jcraft.weirdx.XColormap.java

static void reqStoreNamedColor(Client c) throws IOException {
    int foo, n, len, doc, pixel;
    InputOutput io = c.client;/*w w  w. j a v  a  2s .  co m*/
    doc = c.data;
    n = c.length;
    foo = io.readInt();
    XColormap cmap = (XColormap) XResource.lookupIDByType(foo, XResource.RT_COLORMAP);
    c.length -= 2;
    if (cmap == null) {
        c.errorValue = foo;
        c.errorReason = 12; // Colormap
        return;
    }

    pixel = io.readInt();
    len = io.readShort();
    io.readPad(2);
    n = n - 4;
    n *= 4;
    n -= len;
    io.readByte(c.bbuffer, 0, len);
    io.readPad(n);
    c.length = 0;
    len = chopspace(c.bbuffer, len);
    if (len == 0) {
        c.errorReason = 2; // BadValue
        return;
    }

    String s = new String(c.bbuffer, 0, len);
    Color color = (Color) rgbTable.get(s);
    if (pixel == -1) {
        LOG.warn("?? pixel=" + pixel);
        pixel = 25;
    }

    int red = color.getRed(), green = color.getGreen(), blue = color.getBlue();
    Color cp = cmap.colors[pixel];
    if (cp != null) {
        if (doc != 0) {
            if ((doc & 1) == 0)
                red = cp.getRed();
            if ((doc & 2) == 0)
                green = cp.getGreen();
            if ((doc & 4) == 0)
                blue = cp.getBlue();
        }
    }
    c.errorReason = cmap.storeColor(c, pixel, red, green, blue, doc);
    if (c.errorReason == 0) {
        cmap.mkIcm();
    }
}

From source file:edu.ku.brc.specify.plugins.latlon.LatLonUI.java

/**
 * Creates the UI./*from   w w  w  .  j av a2 s  .  c om*/
 * @param localityCEP the locality object (can be null)
 */
protected void createEditUI() {
    loadAndPushResourceBundle("specify_plugins");

    PanelBuilder builder = new PanelBuilder(new FormLayout("p", "p, 2px, p"), this);

    Color bgColor = getBackground();
    bgColor = new Color(Math.min(bgColor.getRed() + 20, 255), Math.min(bgColor.getGreen() + 20, 255),
            Math.min(bgColor.getBlue() + 20, 255));
    //System.out.println(bgColor);
    setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(bgColor),
            BorderFactory.createEmptyBorder(4, 4, 4, 4)));

    for (int i = 0; i < types.length; i++) {
        typeMapper.put(types[i], typeStrs[i]);
    }

    currentType = LatLonUIIFace.LatLonType.LLPoint;

    pointImages = new ImageIcon[pointNames.length];
    for (int i = 0; i < pointNames.length; i++) {
        pointImages[i] = IconManager.getIcon(pointNames[i], IconManager.IconSize.Std16);
    }

    String[] formatLabels = new String[formats.length];
    for (int i = 0; i < formats.length; i++) {
        formatLabels[i] = getResourceString(formats[i]);
    }
    cardPanel = new JPanel(cardLayout);
    formatSelector = createComboBox(formatLabels);
    latLonPanes = new JComponent[formatLabels.length];

    formatSelector.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            swapForm(formatSelector.getSelectedIndex(), currentType);

            cardLayout.show(cardPanel, ((JComboBox) ae.getSource()).getSelectedItem().toString());

            //stateChanged(null);
        }
    });

    Dimension preferredSize = new Dimension(0, 0);
    cardSubPanes = new JPanel[formats.length * 2];
    panels = new DDDDPanel[formats.length * 2];
    int paneInx = 0;
    for (int i = 0; i < formats.length; i++) {
        cardSubPanes[i] = new JPanel(new BorderLayout());
        try {
            String packageName = "edu.ku.brc.specify.plugins.latlon.";
            DDDDPanel latLon1 = Class.forName(packageName + formatClass[i]).asSubclass(DDDDPanel.class)
                    .newInstance();
            latLon1.setIsRequired(isRequired);
            latLon1.setViewMode(isViewMode);
            latLon1.init();
            latLon1.setChangeListener(this);

            JPanel panel1 = latLon1;
            panel1.setBorder(panelBorder);
            panels[paneInx++] = latLon1;
            latLonPanes[i] = panel1;

            DDDDPanel latlon2 = Class.forName(packageName + formatClass[i]).asSubclass(DDDDPanel.class)
                    .newInstance();
            latlon2.setIsRequired(isRequired);
            latlon2.setViewMode(isViewMode);
            latlon2.init();
            latlon2.setChangeListener(this);

            panels[paneInx++] = latlon2;

            JTabbedPane tabbedPane = new JTabbedPane(
                    UIHelper.getOSType() == UIHelper.OSTYPE.MacOSX ? SwingConstants.BOTTOM
                            : SwingConstants.RIGHT);
            tabbedPane.addTab(null, pointImages[0], panels[paneInx - 2]);
            tabbedPane.addTab(null, pointImages[0], panels[paneInx - 1]);
            latLonPanes[i] = tabbedPane;

            Dimension size = tabbedPane.getPreferredSize();
            preferredSize.width = Math.max(preferredSize.width, size.width);
            preferredSize.height = Math.max(preferredSize.height, size.height);

            tabbedPane.removeAll();
            cardSubPanes[i].add(panel1, BorderLayout.CENTER);
            cardPanel.add(formatLabels[i], cardSubPanes[i]);

            /*if (locality != null)
            {
            latLon1.set(locality.getLatitude1(), locality.getLongitude1(), locality.getLat1text(), locality.getLong1text());
            latlon2.set(locality.getLatitude2(), locality.getLongitude2(), locality.getLat2text(), locality.getLong2text());
            }*/

        } catch (Exception e) {
            e.printStackTrace();
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(LatLonUI.class, e);
        }
    }

    // Makes they are all the same size
    for (int i = 0; i < formats.length; i++) {
        cardSubPanes[i].setPreferredSize(preferredSize);
    }

    //final LatLonPanel thisPanel = this;

    PanelBuilder botBtnBar = new PanelBuilder(new FormLayout("p:g,p,10px,p,10px,p,p:g", "p"));

    ButtonGroup btnGroup = new ButtonGroup();
    botBtns = new JToggleButton[typeNames.length];

    if (UIHelper.isMacOS()) {
        /*for (int i=0;i<botBtns.length;i++)
        {
        ImageIcon selIcon   = IconManager.getIcon(typeNames[i]+"Sel", IconManager.IconSize.Std16);
        ImageIcon unselIcon = IconManager.getIcon(typeNames[i], IconManager.IconSize.Std16);
                
        MacIconRadioButton rb = new MacIconRadioButton(selIcon, unselIcon);
        botBtns[i] = rb;
        rb.setBorder(new MacBtnBorder());
                
        Dimension size = rb.getPreferredSize();
        int max = Math.max(size.width, size.height);
        size.setSize(max, max);
        rb.setPreferredSize(size);
        }*/

        BorderedRadioButton.setSelectedBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
        BorderedRadioButton.setUnselectedBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
        for (int i = 0; i < botBtns.length; i++) {
            BorderedRadioButton rb = new BorderedRadioButton(
                    IconManager.getIcon(typeNames[i], IconManager.IconSize.Std16));
            botBtns[i] = rb;
            rb.makeSquare();
            rb.setBorder(new MacBtnBorder());
        }
    } else {
        BorderedRadioButton.setSelectedBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
        BorderedRadioButton.setUnselectedBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
        for (int i = 0; i < botBtns.length; i++) {
            BorderedRadioButton rb = new BorderedRadioButton(
                    IconManager.getIcon(typeNames[i], IconManager.IconSize.Std16));
            botBtns[i] = rb;
            rb.makeSquare();
        }
    }

    for (int i = 0; i < botBtns.length; i++) {
        botBtns[i].setToolTipText(typeToolTips[i]);
        botBtnBar.add(botBtns[i], cc.xy((i * 2) + 2, 1));
        btnGroup.add(botBtns[i]);
        selectedTypeHash.put(botBtns[i], types[i]);

        botBtns[i].addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ce) {
                stateChanged(null);
                currentType = selectedTypeHash.get(ce.getSource());
                swapForm(formatSelector.getSelectedIndex(), currentType);
            }
        });
    }
    botBtns[0].setSelected(true);

    if (isViewMode) {
        typeLabel = createLabel(" ");
    }

    ActionListener infoAL = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doPrefs();
        }
    };

    JButton infoBtn = UIHelper.createIconBtn("Preferences", IconManager.IconSize.Std16,
            getResourceString("PREFERENCES"), true, infoAL);
    infoBtn.setEnabled(true);

    PanelBuilder topPane = new PanelBuilder(
            new FormLayout("l:p, c:p:g" + (isViewMode ? "" : ",4px,p,8px"), "p"));
    topPane.add(formatSelector, cc.xy(1, 1));
    topPane.add(isViewMode ? typeLabel : botBtnBar.getPanel(), cc.xy(2, 1));
    if (!isViewMode)
        topPane.add(infoBtn, cc.xy(4, 1));

    builder.add(topPane.getPanel(), cc.xy(1, 1));
    builder.add(cardPanel, cc.xy(1, 3));

    prefsPanel = new PrefsPanel(false);
    prefsPanel.add(getResourceString("LatLonUI.LL_SEP"));
    prefsPanel.add(CompType.eCheckbox, getResourceString("LatLonUI.LATDEF_DIR"), LAT_PREF, Boolean.class, true);
    prefsPanel.add(CompType.eCheckbox, getResourceString("LatLonUI.LONDEF_DIR"), LON_PREF, Boolean.class, true);
    prefsPanel.add(CompType.eComboBox, getResourceString("LatLonUI.DEF_TYP"), TYP_PREF, Integer.class,
            typeNamesLabels, 0);
    prefsPanel.add(CompType.eComboBox, getResourceString("LatLonUI.DEF_FMT"), FMT_PREF, Integer.class,
            formatLabels, 0);
    prefsPanel.createForm(null, null);

    popResourceBundle();
}

From source file:com.hp.autonomy.frontend.reports.powerpoint.PowerPointServiceImpl.java

/**
 * Internal implementation to add a topic map to a slide.
 * @param slide the slide to add to.// www  .  j a v  a  2 s . c o m
 * @param anchor bounding rectangle to draw onto, in PowerPoint coordinates.
 * @param data the topic map data.
 */
private static void addTopicMap(final XSLFSlide slide, final Rectangle2D.Double anchor,
        final TopicMapData data) {
    for (final TopicMapData.Path reqPath : data.getPaths()) {
        final XSLFFreeformShape shape = slide.createFreeform();
        final Path2D.Double path = new Path2D.Double();

        boolean first = true;

        for (double[] point : reqPath.getPoints()) {
            final double x = point[0] * anchor.getWidth() + anchor.getMinX();
            final double y = point[1] * anchor.getHeight() + anchor.getMinY();
            if (first) {
                path.moveTo(x, y);
                first = false;
            } else {
                path.lineTo(x, y);
            }
        }
        path.closePath();

        shape.setPath(path);
        shape.setStrokeStyle(2);
        shape.setLineColor(Color.GRAY);
        shape.setHorizontalCentered(true);
        shape.setVerticalAlignment(VerticalAlignment.MIDDLE);
        shape.setTextAutofit(TextShape.TextAutofit.NORMAL);

        final XSLFTextParagraph text = shape.addNewTextParagraph();
        final XSLFTextRun textRun = text.addNewTextRun();
        textRun.setText(reqPath.name);
        textRun.setFontColor(Color.WHITE);
        textRun.setBold(true);

        final CTShape cs = (CTShape) shape.getXmlObject();

        double max = 100, min = 1, scale = 100;
        final CTTextNormalAutofit autoFit = cs.getTxBody().getBodyPr().getNormAutofit();
        final double availHeight = path.getBounds2D().getHeight();
        final int RESIZE_ATTEMPTS = 7;

        for (int attempts = 0; attempts < RESIZE_ATTEMPTS; ++attempts) {
            // PowerPoint doesn't resize the text till you edit it once, which means the text initially looks too
            //   large when you first view the slide; so we binary-chop to get a sensible initial approximation.
            // OpenOffice does the text resize on load so it doesn't have this problem.
            autoFit.setFontScale(Math.max(1, (int) (scale * 1000)));

            final double textHeight = shape.getTextHeight();
            if (textHeight < availHeight) {
                min = scale;
                scale = 0.5 * (min + max);
            } else if (textHeight > availHeight) {
                max = scale;
                scale = 0.5 * (min + max);
            } else {
                break;
            }
        }

        final int opacity = (int) (100000 * reqPath.getOpacity());
        final Color c1 = Color.decode(reqPath.getColor());
        final Color c2 = Color.decode(reqPath.getColor2());

        final CTGradientFillProperties gFill = cs.getSpPr().addNewGradFill();
        gFill.addNewLin().setAng(3300000);
        final CTGradientStopList list = gFill.addNewGsLst();

        final CTGradientStop stop1 = list.addNewGs();
        stop1.setPos(0);
        final CTSRgbColor color1 = stop1.addNewSrgbClr();
        color1.setVal(new byte[] { (byte) c1.getRed(), (byte) c1.getGreen(), (byte) c1.getBlue() });
        color1.addNewAlpha().setVal(opacity);

        final CTGradientStop stop2 = list.addNewGs();
        stop2.setPos(100000);
        final CTSRgbColor color2 = stop2.addNewSrgbClr();
        color2.setVal(new byte[] { (byte) c2.getRed(), (byte) c2.getGreen(), (byte) c2.getBlue() });
        color2.addNewAlpha().setVal(opacity);

        if (reqPath.level > 0) {
            // The nodes which aren't leaf nodes can be clicked on to hide them so you can see the nodes underneath.
            // This only works in PowerPoint; OpenOffice doesn't seem to support it. OpenOffice has its own syntax
            //   to do something similar, but we don't use it since PowerPoint treats it as corrupt.
            final String shapeId = Integer.toString(shape.getShapeId());
            final CTSlide slXML = slide.getXmlObject();

            final CTTimeNodeList childTnLst;
            final CTBuildList bldLst;
            if (!slXML.isSetTiming()) {
                final CTSlideTiming timing = slXML.addNewTiming();
                final CTTLCommonTimeNodeData ctn = timing.addNewTnLst().addNewPar().addNewCTn();
                ctn.setDur("indefinite");
                ctn.setRestart(STTLTimeNodeRestartTypeImpl.NEVER);
                ctn.setNodeType(STTLTimeNodeType.TM_ROOT);
                childTnLst = ctn.addNewChildTnLst();
                bldLst = timing.addNewBldLst();
            } else {
                final CTSlideTiming timing = slXML.getTiming();
                childTnLst = timing.getTnLst().getParArray(0).getCTn().getChildTnLst();
                bldLst = timing.getBldLst();
            }

            final CTTLTimeNodeSequence seq = childTnLst.addNewSeq();
            seq.setConcurrent(true);
            seq.setNextAc(STTLNextActionType.SEEK);
            final CTTLCommonTimeNodeData common = seq.addNewCTn();

            common.setRestart(STTLTimeNodeRestartType.WHEN_NOT_ACTIVE);
            common.setFill(STTLTimeNodeFillType.HOLD);
            common.setEvtFilter("cancelBubble");
            common.setNodeType(STTLTimeNodeType.INTERACTIVE_SEQ);

            final CTTLTimeConditionList condList = common.addNewStCondLst();
            final CTTLTimeCondition cond = condList.addNewCond();
            cond.setEvt(STTLTriggerEvent.ON_CLICK);
            cond.setDelay(0);
            cond.addNewTgtEl().addNewSpTgt().setSpid(shapeId);

            final CTTLTimeCondition endSync = common.addNewEndSync();
            endSync.setEvt(STTLTriggerEvent.END);
            endSync.setDelay(0);
            endSync.addNewRtn().setVal(STTLTriggerRuntimeNode.ALL);

            // These holdCtn* 'hold' transitions with zero delay might seem redundant; but they're exported in the
            //   PowerPoint XML, and the online PowerPoint Office365 viewer won't support the click animations
            //   unless they're present (e.g. from the 'Start Slide Show' button in the browser).
            final CTTLCommonTimeNodeData holdCtn1 = common.addNewChildTnLst().addNewPar().addNewCTn();

            holdCtn1.setFill(STTLTimeNodeFillType.HOLD);
            holdCtn1.addNewStCondLst().addNewCond().setDelay(0);

            final CTTLCommonTimeNodeData holdCtn2 = holdCtn1.addNewChildTnLst().addNewPar().addNewCTn();

            holdCtn2.setFill(STTLTimeNodeFillType.HOLD);
            holdCtn2.addNewStCondLst().addNewCond().setDelay(0);

            final CTTLCommonTimeNodeData clickCtn = holdCtn2.addNewChildTnLst().addNewPar().addNewCTn();

            clickCtn.setPresetID(10);
            clickCtn.setPresetClass(STTLTimeNodePresetClassType.EXIT);
            clickCtn.setPresetSubtype(0);
            clickCtn.setFill(STTLTimeNodeFillType.HOLD);
            clickCtn.setGrpId(0);
            clickCtn.setNodeType(STTLTimeNodeType.CLICK_EFFECT);

            clickCtn.addNewStCondLst().addNewCond().setDelay(0);

            final CTTimeNodeList clickChildTnList = clickCtn.addNewChildTnLst();

            final CTTLAnimateEffectBehavior animEffect = clickChildTnList.addNewAnimEffect();
            animEffect.setTransition(STTLAnimateEffectTransition.OUT);
            animEffect.setFilter("fade");
            final CTTLCommonBehaviorData cBhvr = animEffect.addNewCBhvr();
            final CTTLCommonTimeNodeData bhvrCtn = cBhvr.addNewCTn();

            bhvrCtn.setDur(500);
            cBhvr.addNewTgtEl().addNewSpTgt().setSpid(shapeId);

            final CTTLSetBehavior clickSet = clickChildTnList.addNewSet();
            final CTTLCommonBehaviorData clickSetBhvr = clickSet.addNewCBhvr();
            final CTTLCommonTimeNodeData hideCtn = clickSetBhvr.addNewCTn();

            hideCtn.setDur(1);
            hideCtn.setFill(STTLTimeNodeFillType.HOLD);
            hideCtn.addNewStCondLst().addNewCond().setDelay(499);

            clickSetBhvr.addNewTgtEl().addNewSpTgt().setSpid(shapeId);
            clickSetBhvr.addNewAttrNameLst().addAttrName("style.visibility");
            clickSet.addNewTo().addNewStrVal().setVal("hidden");

            final CTTLBuildParagraph bldP = bldLst.addNewBldP();
            bldP.setSpid(shapeId);
            bldP.setGrpId(0);
            bldP.setAnimBg(true);
        }
    }
}