Example usage for java.util Vector addAll

List of usage examples for java.util Vector addAll

Introduction

In this page you can find the example usage for java.util Vector addAll.

Prototype

public boolean addAll(Collection<? extends E> c) 

Source Link

Document

Appends all of the elements in the specified Collection to the end of this Vector, in the order that they are returned by the specified Collection's Iterator.

Usage

From source file:org.openflexo.foundation.ie.widget.IEBlocWidget.java

@Override
public Vector<IESequenceTab> getAllTabContainers() {
    Vector<IESequenceTab> reply = new Vector<IESequenceTab>();
    if (_innerBloc == null) {
        return reply;
    }/* w w  w  . jav  a 2  s  . c  o  m*/
    if (_innerBloc instanceof IESequenceTab) {
        reply.add((IESequenceTab) _innerBloc);
    }
    if (_innerBloc instanceof IEHTMLTableWidget) {
        reply.addAll(((IEHTMLTableWidget) _innerBloc).getAllTabContainers());
    }
    return reply;
}

From source file:edu.umn.cs.spatialHadoop.visualization.MultilevelPlot.java

private static void plotLocal(Path[] inFiles, final Path outPath, final Class<? extends Plotter> plotterClass,
        final OperationsParams params) throws IOException, InterruptedException, ClassNotFoundException {
    final boolean vflip = params.getBoolean("vflip", true);

    OperationsParams mbrParams = new OperationsParams(params);
    mbrParams.setBoolean("background", false);
    final Rectangle inputMBR = params.get("mbr") != null ? params.getShape("mbr").getMBR()
            : FileMBR.fileMBR(inFiles, mbrParams);
    OperationsParams.setShape(params, InputMBR, inputMBR);

    // Retrieve desired output image size and keep aspect ratio if needed
    int tileWidth = params.getInt("tilewidth", 256);
    int tileHeight = params.getInt("tileheight", 256);
    // Adjust width and height if aspect ratio is to be kept
    if (params.getBoolean("keepratio", true)) {
        // Expand input file to a rectangle for compatibility with the pyramid
        // structure
        if (inputMBR.getWidth() > inputMBR.getHeight()) {
            inputMBR.y1 -= (inputMBR.getWidth() - inputMBR.getHeight()) / 2;
            inputMBR.y2 = inputMBR.y1 + inputMBR.getWidth();
        } else {//w ww .  j ava2  s.c om
            inputMBR.x1 -= (inputMBR.getHeight() - inputMBR.getWidth()) / 2;
            inputMBR.x2 = inputMBR.x1 + inputMBR.getHeight();
        }
    }

    String outFName = outPath.getName();
    int extensionStart = outFName.lastIndexOf('.');
    final String extension = extensionStart == -1 ? ".png" : outFName.substring(extensionStart);

    // Start reading input file
    Vector<InputSplit> splits = new Vector<InputSplit>();
    final SpatialInputFormat3<Rectangle, Shape> inputFormat = new SpatialInputFormat3<Rectangle, Shape>();
    for (Path inFile : inFiles) {
        FileSystem inFs = inFile.getFileSystem(params);
        if (!OperationsParams.isWildcard(inFile) && inFs.exists(inFile) && !inFs.isDirectory(inFile)) {
            if (SpatialSite.NonHiddenFileFilter.accept(inFile)) {
                // Use the normal input format splitter to add this non-hidden file
                Job job = Job.getInstance(params);
                SpatialInputFormat3.addInputPath(job, inFile);
                splits.addAll(inputFormat.getSplits(job));
            } else {
                // A hidden file, add it immediately as one split
                // This is useful if the input is a hidden file which is automatically
                // skipped by FileInputFormat. We need to plot a hidden file for the case
                // of plotting partition boundaries of a spatial index
                splits.add(new FileSplit(inFile, 0, inFs.getFileStatus(inFile).getLen(), new String[0]));
            }
        } else {
            Job job = Job.getInstance(params);
            SpatialInputFormat3.addInputPath(job, inFile);
            splits.addAll(inputFormat.getSplits(job));
        }
    }

    try {
        Plotter plotter = plotterClass.newInstance();
        plotter.configure(params);

        String[] strLevels = params.get("levels", "7").split("\\.\\.");
        int minLevel, maxLevel;
        if (strLevels.length == 1) {
            minLevel = 0;
            maxLevel = Integer.parseInt(strLevels[0]);
        } else {
            minLevel = Integer.parseInt(strLevels[0]);
            maxLevel = Integer.parseInt(strLevels[1]);
        }

        GridInfo bottomGrid = new GridInfo(inputMBR.x1, inputMBR.y1, inputMBR.x2, inputMBR.y2);
        bottomGrid.rows = bottomGrid.columns = 1 << maxLevel;

        TileIndex key = new TileIndex();

        // All canvases in the pyramid, one per tile
        Map<TileIndex, Canvas> canvases = new HashMap<TileIndex, Canvas>();
        for (InputSplit split : splits) {
            FileSplit fsplit = (FileSplit) split;
            RecordReader<Rectangle, Iterable<Shape>> reader = inputFormat.createRecordReader(fsplit, null);
            if (reader instanceof SpatialRecordReader3) {
                ((SpatialRecordReader3) reader).initialize(fsplit, params);
            } else if (reader instanceof RTreeRecordReader3) {
                ((RTreeRecordReader3) reader).initialize(fsplit, params);
            } else if (reader instanceof HDFRecordReader) {
                ((HDFRecordReader) reader).initialize(fsplit, params);
            } else {
                throw new RuntimeException("Unknown record reader");
            }

            while (reader.nextKeyValue()) {
                Rectangle partition = reader.getCurrentKey();
                if (!partition.isValid())
                    partition.set(inputMBR);

                Iterable<Shape> shapes = reader.getCurrentValue();

                for (Shape shape : shapes) {
                    Rectangle shapeMBR = shape.getMBR();
                    if (shapeMBR == null)
                        continue;
                    java.awt.Rectangle overlappingCells = bottomGrid.getOverlappingCells(shapeMBR);
                    // Iterate over levels from bottom up
                    for (key.level = maxLevel; key.level >= minLevel; key.level--) {
                        for (key.x = overlappingCells.x; key.x < overlappingCells.x
                                + overlappingCells.width; key.x++) {
                            for (key.y = overlappingCells.y; key.y < overlappingCells.y
                                    + overlappingCells.height; key.y++) {
                                Canvas canvas = canvases.get(key);
                                if (canvas == null) {
                                    Rectangle tileMBR = new Rectangle();
                                    int gridSize = 1 << key.level;
                                    tileMBR.x1 = (inputMBR.x1 * (gridSize - key.x) + inputMBR.x2 * key.x)
                                            / gridSize;
                                    tileMBR.x2 = (inputMBR.x1 * (gridSize - (key.x + 1))
                                            + inputMBR.x2 * (key.x + 1)) / gridSize;
                                    tileMBR.y1 = (inputMBR.y1 * (gridSize - key.y) + inputMBR.y2 * key.y)
                                            / gridSize;
                                    tileMBR.y2 = (inputMBR.y1 * (gridSize - (key.y + 1))
                                            + inputMBR.y2 * (key.y + 1)) / gridSize;
                                    canvas = plotter.createCanvas(tileWidth, tileHeight, tileMBR);
                                    canvases.put(key.clone(), canvas);
                                }
                                plotter.plot(canvas, shape);
                            }
                        }
                        // Update overlappingCells for the higher level
                        int updatedX1 = overlappingCells.x / 2;
                        int updatedY1 = overlappingCells.y / 2;
                        int updatedX2 = (overlappingCells.x + overlappingCells.width - 1) / 2;
                        int updatedY2 = (overlappingCells.y + overlappingCells.height - 1) / 2;
                        overlappingCells.x = updatedX1;
                        overlappingCells.y = updatedY1;
                        overlappingCells.width = updatedX2 - updatedX1 + 1;
                        overlappingCells.height = updatedY2 - updatedY1 + 1;
                    }
                }
            }
            reader.close();
        }

        // Done with all splits. Write output to disk
        LOG.info("Done with plotting. Now writing the output");
        final FileSystem outFS = outPath.getFileSystem(params);

        LOG.info("Writing default empty image");
        // Write a default empty image to be displayed for non-generated tiles
        BufferedImage emptyImg = new BufferedImage(tileWidth, tileHeight, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = new SimpleGraphics(emptyImg);
        g.setBackground(new Color(0, 0, 0, 0));
        g.clearRect(0, 0, tileWidth, tileHeight);
        g.dispose();

        // Write HTML file to browse the mutlielvel image
        OutputStream out = outFS.create(new Path(outPath, "default.png"));
        ImageIO.write(emptyImg, "png", out);
        out.close();

        // Add an HTML file that visualizes the result using Google Maps
        LOG.info("Writing the HTML viewer file");
        LineReader templateFileReader = new LineReader(
                MultilevelPlot.class.getResourceAsStream("/zoom_view.html"));
        PrintStream htmlOut = new PrintStream(outFS.create(new Path(outPath, "index.html")));
        Text line = new Text();
        while (templateFileReader.readLine(line) > 0) {
            String lineStr = line.toString();
            lineStr = lineStr.replace("#{TILE_WIDTH}", Integer.toString(tileWidth));
            lineStr = lineStr.replace("#{TILE_HEIGHT}", Integer.toString(tileHeight));
            lineStr = lineStr.replace("#{MAX_ZOOM}", Integer.toString(maxLevel));
            lineStr = lineStr.replace("#{MIN_ZOOM}", Integer.toString(minLevel));
            lineStr = lineStr.replace("#{TILE_URL}",
                    "'tile-' + zoom + '-' + coord.x + '-' + coord.y + '" + extension + "'");

            htmlOut.println(lineStr);
        }
        templateFileReader.close();
        htmlOut.close();

        // Write the tiles
        final Entry<TileIndex, Canvas>[] entries = canvases.entrySet().toArray(new Map.Entry[canvases.size()]);
        // Clear the hash map to save memory as it is no longer needed
        canvases.clear();
        int parallelism = params.getInt("parallel", Runtime.getRuntime().availableProcessors());
        Parallel.forEach(entries.length, new RunnableRange<Object>() {
            @Override
            public Object run(int i1, int i2) {
                boolean output = params.getBoolean("output", true);
                try {
                    Plotter plotter = plotterClass.newInstance();
                    plotter.configure(params);
                    for (int i = i1; i < i2; i++) {
                        Map.Entry<TileIndex, Canvas> entry = entries[i];
                        TileIndex key = entry.getKey();
                        if (vflip)
                            key.y = ((1 << key.level) - 1) - key.y;

                        Path imagePath = new Path(outPath, key.getImageFileName() + extension);
                        // Write this tile to an image
                        DataOutputStream outFile = output ? outFS.create(imagePath)
                                : new DataOutputStream(new NullOutputStream());
                        plotter.writeImage(entry.getValue(), outFile, vflip);
                        outFile.close();

                        // Remove entry to allows GC to collect it
                        entries[i] = null;
                    }
                    return null;
                } catch (InstantiationException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return null;
            }
        }, parallelism);
    } catch (InstantiationException e) {
        throw new RuntimeException("Error creating rastierizer", e);
    } catch (IllegalAccessException e) {
        throw new RuntimeException("Error creating rastierizer", e);
    }
}

From source file:net.sf.taverna.t2.activities.wsdl.wss4j.T2WSDoAllSender.java

/**                                                             
 * Performs all defined security actions to set-up the SOAP request.
 * //from   w w w . j ava 2 s.c  o  m
 * This method overrides the doSenderAction() method of WSHandler class
 * by setting the actions to be executed to use T2 security agents.
 * 
 * 
 * @param doAction a set defining the actions to do 
 * @param doc   the request as DOM document 
 * @param reqData a data storage to pass values around bewteen methods
 * @param actions a vector holding the actions to do in the order defined
 *                in the deployment file or property
 * @throws WSSecurityException
 */
@Override
protected void doSenderAction(int doAction, Document doc, RequestData reqData, Vector actions,
        boolean isRequest) throws WSSecurityException {

    boolean mu = decodeMustUnderstand(reqData);

    WSSConfig wssConfig = WSSConfig.getNewInstance();

    wssConfig.setEnableSignatureConfirmation(decodeEnableSignatureConfirmation(reqData));

    wssConfig.setPrecisionInMilliSeconds(decodeTimestampPrecision(reqData));
    reqData.setWssConfig(wssConfig);

    Object mc = reqData.getMsgContext();
    String actor = getString(WSHandlerConstants.ACTOR, mc);
    reqData.setActor(actor);

    WSSecHeader secHeader = new WSSecHeader(actor, mu);
    secHeader.insertSecurityHeader(doc);

    reqData.setSecHeader(secHeader);
    reqData.setSoapConstants(WSSecurityUtil.getSOAPConstants(doc.getDocumentElement()));
    /*
     * Here we have action, username, password, and actor, mustUnderstand.
     * Now get the action specific parameters.
     */
    if ((doAction & WSConstants.UT) == WSConstants.UT) {
        decodeUTParameter(reqData);
    }
    /*
     * Here we have action, username, password, and actor, mustUnderstand.
     * Now get the action specific parameters.
     */
    if ((doAction & WSConstants.UT_SIGN) == WSConstants.UT_SIGN) {
        decodeUTParameter(reqData);
        decodeSignatureParameter(reqData);
    }
    /*
     * Get and check the Signature specific parameters first because they
     * may be used for encryption too.
     */
    if ((doAction & WSConstants.SIGN) == WSConstants.SIGN) {
        reqData.setSigCrypto(loadSignatureCrypto(reqData));
        decodeSignatureParameter(reqData);
    }
    /*
     * If we need to handle signed SAML token then we need may of the
     * Signature parameters. The handle procedure loads the signature crypto
     * file on demand, thus don't do it here.
     */
    if ((doAction & WSConstants.ST_SIGNED) == WSConstants.ST_SIGNED) {
        decodeSignatureParameter(reqData);
    }
    /*
     * Set and check the encryption specific parameters, if necessary take
     * over signature parameters username and crypto instance.
     */
    if ((doAction & WSConstants.ENCR) == WSConstants.ENCR) {
        reqData.setEncCrypto(loadEncryptionCrypto(reqData));
        decodeEncryptionParameter(reqData);
    }
    /*
     * If after all the parsing no Signature parts defined, set here a
     * default set. This is necessary because we add SignatureConfirmation
     * and therefore the default (Body) must be set here. The default setting
     * in WSSignEnvelope doesn't work because the vector is not empty anymore.
     */
    if (reqData.getSignatureParts().isEmpty()) {
        WSEncryptionPart encP = new WSEncryptionPart(reqData.getSoapConstants().getBodyQName().getLocalPart(),
                reqData.getSoapConstants().getEnvelopeURI(), "Content");
        reqData.getSignatureParts().add(encP);
    }
    /*
     * If SignatureConfirmation is enabled and this is a reqsponse then
     * insert SignatureCOnfrmation elements, note their wsu:id in the signature
     * parts. They will be signed automatically during a (probably) defined
     * SIGN action.
     */
    if (wssConfig.isEnableSignatureConfirmation() && !isRequest) {
        String done;
        if ((done = (String) getProperty(reqData.getMsgContext(), WSHandlerConstants.SIG_CONF_DONE)) == null
                || !DONE.equals(done)) {
            Vector results = null;
            if ((results = (Vector) getProperty(reqData.getMsgContext(),
                    WSHandlerConstants.RECV_RESULTS)) != null) {
                wssConfig.getAction(WSConstants.SC).execute(this, WSConstants.SC, doc, reqData);
            }
        }
    }
    /*
     * Here we have all necessary information to perform the requested
     * action(s).
     */

    // Get the security agent
    /* WSSecurityAgent sa = (WSSecurityAgent) ((MessageContext)reqData.getMsgContext()).getProperty("security_agent");
            
     // Perform security actions
     for (int i = 0; i < actions.size(); i++) {
            
    int actionToDo = ((Integer) actions.get(i)).intValue();
    if (doDebug) {
        log.debug("Performing Action: " + actionToDo);
    }
            
    switch (actionToDo) {
        case WSConstants.UT:{
           try {
           sa.wssUsernameToken(doc, reqData);
        } catch (SAException e) {
           logger.error("", e);
        } break;
    }
        case WSConstants.ENCR:
        case WSConstants.SIGN:{//sa.wssSign(doc, reqData); break;}
        case WSConstants.ST_SIGNED:
        case WSConstants.ST_UNSIGNED:
        case WSConstants.TS:
        case WSConstants.UT_SIGN:
            wssConfig.getAction(actionToDo).execute(this, actionToDo, doc, reqData);
            break;
        case WSConstants.NO_SERIALIZE:
            reqData.setNoSerialization(true);
            break;
    }
     } */

    /*
     * If this is a request then store all signature values. Add ours to
     * already gathered values because of chained handlers, e.g. for
     * other actors.
     */

    if (wssConfig.isEnableSignatureConfirmation() && isRequest) {
        if (reqData.getSignatureValues().size() > 0) {
            Vector sigv = null;
            if ((sigv = (Vector) getProperty(reqData.getMsgContext(), WSHandlerConstants.SEND_SIGV)) == null) {
                sigv = new Vector();
                setProperty(reqData.getMsgContext(), WSHandlerConstants.SEND_SIGV, sigv);
            }
            // sigv.add(reqData.getSignatureValues());
            sigv.addAll(reqData.getSignatureValues());
        }
    }
}

From source file:net.sf.jsptest.compiler.jsp20.mock.MockHttpServletRequest.java

public Enumeration getHeaders(String name) {
    Vector vector = new Vector();
    List values = (List) headers.get(resolveHeaderName(name));
    if (values != null) {
        vector.addAll(values);
    }/*from ww w.  jav a  2s. c  o  m*/
    return vector.elements();
}

From source file:org.kchine.r.server.RListener.java

public static String[] forbiddenSymbols(String voidStr) {
    if (_forbiddenSymbols == null) {
        Vector<String> v = new Vector<String>();
        v.addAll(DirectJNI.getInstance().getBootStrapRObjects());
        v.add("ls");
        v.add("objects");
        v.add("q");
        v.add("win.graph");
        v.add("x11");
        v.add("X11");
        v.add("dev.off");
        v.add("graphics.off");
        v.add("dev.set");
        v.add("help");
        v.add("setwd");
        _forbiddenSymbols = (String[]) v.toArray(new String[0]);
    }//from  w  ww.j  ava2 s  .co m
    return _forbiddenSymbols;
}

From source file:net.sf.mzmine.modules.peaklistmethods.dataanalysis.heatmaps.HeatMapTask.java

private double[][] modifySimpleDataset(UserParameter selectedParameter, String referenceGroup) {

    // Collect all data files
    Vector<RawDataFile> allDataFiles = new Vector<RawDataFile>();
    allDataFiles.addAll(Arrays.asList(peakList.getRawDataFiles()));

    // Determine the reference group and non reference group (the rest of
    // the samples) for raw data files
    List<RawDataFile> referenceDataFiles = new ArrayList<RawDataFile>();
    List<RawDataFile> nonReferenceDataFiles = new ArrayList<RawDataFile>();

    MZmineProject project = MZmineCore.getCurrentProject();
    for (RawDataFile rawDataFile : allDataFiles) {

        Object paramValue = project.getParameterValue(selectedParameter, rawDataFile);

        if (paramValue.equals(referenceGroup)) {

            referenceDataFiles.add(rawDataFile);
        } else {/*w  w  w  . j a  va  2 s.  com*/

            nonReferenceDataFiles.add(rawDataFile);
        }
    }

    int numRows = 0;
    for (int row = 0; row < peakList.getNumberOfRows(); row++) {

        if (!onlyIdentified || (onlyIdentified && peakList.getRow(row).getPeakIdentities().length > 0)) {
            numRows++;
        }
    }

    // Create a new aligned peak list with all the samples if the reference
    // group has to be shown or with only
    // the non reference group if not.
    double[][] dataMatrix;
    if (rcontrol) {
        dataMatrix = new double[allDataFiles.size()][numRows];
    } else {
        dataMatrix = new double[nonReferenceDataFiles.size()][numRows];
    }

    // Data files that should be in the heat map
    List<RawDataFile> shownDataFiles = null;
    if (rcontrol) {
        shownDataFiles = allDataFiles;
    } else {
        shownDataFiles = nonReferenceDataFiles;
    }

    for (int row = 0, rowIndex = 0; row < peakList.getNumberOfRows(); row++) {
        PeakListRow rowPeak = peakList.getRow(row);
        if (!onlyIdentified || (onlyIdentified && rowPeak.getPeakIdentities().length > 0)) {

            // Average area or height of the reference group
            double referenceAverage = 0;
            int referencePeakCount = 0;
            for (int column = 0; column < referenceDataFiles.size(); column++) {

                if (rowPeak.getPeak(referenceDataFiles.get(column)) != null) {

                    if (area) {

                        referenceAverage += rowPeak.getPeak(referenceDataFiles.get(column)).getArea();
                    } else {

                        referenceAverage += rowPeak.getPeak(referenceDataFiles.get(column)).getHeight();
                    }
                    referencePeakCount++;
                }
            }
            if (referencePeakCount > 0) {

                referenceAverage /= referencePeakCount;
            }

            // Divide the area or height of each peak by the average of the
            // area or height of the reference peaks in each row
            for (int column = 0; column < shownDataFiles.size(); column++) {
                double value = Double.NaN;
                if (rowPeak.getPeak(shownDataFiles.get(column)) != null) {

                    Feature peak = rowPeak.getPeak(shownDataFiles.get(column));
                    if (area) {

                        value = peak.getArea() / referenceAverage;
                    } else {

                        value = peak.getHeight() / referenceAverage;
                    }
                    if (log) {

                        value = Math.log(value);
                    }
                }

                dataMatrix[column][rowIndex] = value;
            }
            rowIndex++;
        }
    }

    // Scale the data dividing the peak area/height by the standard
    // deviation of each column
    if (scale) {
        scale(dataMatrix);
    }

    // Create two arrays: row and column names
    rowNames = new String[dataMatrix[0].length];
    colNames = new String[shownDataFiles.size()];

    for (int column = 0; column < shownDataFiles.size(); column++) {

        colNames[column] = shownDataFiles.get(column).getName();
    }
    for (int row = 0, rowIndex = 0; row < peakList.getNumberOfRows(); row++) {
        if (!onlyIdentified || (onlyIdentified && peakList.getRow(row).getPeakIdentities().length > 0)) {
            if (peakList.getRow(row).getPeakIdentities() != null
                    && peakList.getRow(row).getPeakIdentities().length > 0) {

                rowNames[rowIndex++] = peakList.getRow(row).getPreferredPeakIdentity().getName();
            } else {

                rowNames[rowIndex++] = "Unknown";
            }
        }
    }

    return dataMatrix;
}

From source file:org.openmrs.module.solr.web.DWRChartSearchService.java

/**
 * Returns a map of results with the values as count of matches and a partial list of the
 * matching concepts (depending on values of start and length parameters) while the keys are are
 * 'count' and 'objectList' respectively, if the length parameter is not specified, then all
 * matches will be returned from the start index if specified.
 * //from  w  ww .ja  v  a 2  s .  c  o  m
 * @param phrase concept name or conceptId
 * @param includeRetired boolean if false, will exclude retired concepts
 * @param includeClassNames List of ConceptClasses to restrict to
 * @param excludeClassNames List of ConceptClasses to leave out of results
 * @param includeDatatypeNames List of ConceptDatatypes to restrict to
 * @param excludeDatatypeNames List of ConceptDatatypes to leave out of results
 * @param start the beginning index
 * @param length the number of matching concepts to return
 * @param getMatchCount Specifies if the count of matches should be included in the returned map
 * @return a map of results
 * @throws APIException
 * @since 1.8
 */
public Map<String, Object> findCountAndConcepts(Integer patientId, String phrase, boolean includeRetired,
        List<String> includeClassNames, List<String> excludeClassNames, List<String> includeDatatypeNames,
        List<String> excludeDatatypeNames, Integer start, Integer length, boolean getMatchCount)
        throws APIException {
    //Map to return
    Map<String, Object> resultsMap = new HashMap<String, Object>();
    Vector<Object> objectList = new Vector<Object>();

    try {
        if (!StringUtils.isBlank(phrase)) {

            long matchCount = 0;
            if (getMatchCount) {
                //get the count of matches
                matchCount += getDocumentListCount(patientId, phrase);
            }

            //if we have any matches or this isn't the first ajax call when the caller
            //requests for the count
            if (matchCount > 0 || !getMatchCount) {
                objectList.addAll(findBatchOfConcepts(patientId, phrase, includeRetired, includeClassNames,
                        excludeClassNames, includeDatatypeNames, excludeDatatypeNames, start, length));
            }

            resultsMap.put("count", matchCount);
            resultsMap.put("objectList", objectList);
        } else {
            resultsMap.put("count", 0);
            objectList.add(Context.getMessageSourceService().getMessage("searchWidget.noMatchesFound"));
        }

    } catch (Exception e) {
        log.error("Error while searching for concepts", e);
        objectList.clear();
        objectList.add(
                Context.getMessageSourceService().getMessage("Concept.search.error") + " - " + e.getMessage());
        resultsMap.put("count", 0);
        resultsMap.put("objectList", objectList);
    }

    return resultsMap;
}

From source file:org.spiderplan.tools.visulization.GraphFrame.java

@Override
public void actionPerformed(ActionEvent ae) {
    Component source = (Component) ae.getSource();

    if (source.getName().equals("SwitchMode")) {
        if (this.mode == Mode.Transformation) {
            switchMode.setText("Transformation");
            this.mode = Mode.Picking;
            graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
        } else {//from  ww  w.  j  a  v a 2 s  . co  m
            switchMode.setText("Picking");
            this.mode = Mode.Transformation;
            graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
        }
    } else if (source.getName().equals("Dump")) {
        this.writeJPEGImage("screenshot.png", "png");
    } else if (source.getName().equals("Subgraph")) {

        PickedState<V> selection = vv.getPickedVertexState();

        if (selection.getPicked().size() > 0) {
            int depth = Integer.valueOf(subGraphDepth.getText()).intValue();

            GraphTools<V, E> cG = new GraphTools<V, E>();

            Vector<V> connected = new Vector<V>();
            connected.addAll(selection.getPicked());
            Vector<V> checked = new Vector<V>();

            for (int i = 0; i < depth; i++) {
                Vector<V> addList = new Vector<V>();
                for (V v1 : connected) {
                    if (!checked.contains(v1)) {
                        checked.add(v1);
                        for (V v2 : g.getNeighbors(v1)) {
                            if (!connected.contains(v2)) {
                                addList.add(v2);
                            }
                        }
                    }
                }
                for (V v : addList) {
                    connected.add(v);
                }
            }

            AbstractTypedGraph<V, E> subGraph;
            if (this.defaultEdgeType == EdgeType.UNDIRECTED) {
                subGraph = cG.copyUndirSparseMultiGraph(g);
            } else {
                subGraph = cG.copyDirSparseMultiGraph(g);
            }

            Vector<V> removeList = new Vector<V>();
            for (V v : subGraph.getVertices()) {
                if (!connected.contains(v)) {
                    removeList.add(v);
                }
            }
            for (V v : removeList) {
                subGraph.removeVertex(v);
            }
            new GraphFrame<V, E>(subGraph, null, "Sub Graph " + subGraphCounter, this.layoutClass,
                    this.edgeLabels);

            subGraphCounter++;
        }
    } else if (source.getName().equals("SelectLayout")) {
        @SuppressWarnings("rawtypes")
        JComboBox box = (JComboBox) source;

        String selection = box.getSelectedItem().toString();

        if (selection.equals("FR")) {
            this.setLayout(LayoutClass.FR);
        } else if (selection.equals("FR2")) {
            this.setLayout(LayoutClass.FR2);
        } else if (selection.equals("Static")) {
            this.setLayout(LayoutClass.Static);
        } else if (selection.equals("Circle")) {
            this.setLayout(LayoutClass.Circle);
        } else if (selection.equals("DAG")) {
            this.setLayout(LayoutClass.DAG);
        } else if (selection.equals("Spring")) {
            this.setLayout(LayoutClass.Spring);
        } else if (selection.equals("Spring2")) {
            this.setLayout(LayoutClass.Spring2);
        } else if (selection.equals("ISOM")) {
            this.setLayout(LayoutClass.ISOM);
        } else if (selection.equals("PolarPoint")) {
            this.setLayout(LayoutClass.PolarPoint);
        } else if (selection.equals("KK")) {
            this.setLayout(LayoutClass.KK);
        }

        Dimension d = vv.getSize();//new Dimension(600,600);
        layout.setSize(d);

        try {
            Relaxer relaxer = new VisRunner((IterativeContext) layout);
            relaxer.stop();
            relaxer.prerelax();
        } catch (java.lang.ClassCastException e) {
        }

        StaticLayout<V, E> staticLayout = new StaticLayout<V, E>(g, layout);
        LayoutTransition<V, E> lt = new LayoutTransition<V, E>(vv, vv.getGraphLayout(), staticLayout);
        Animator animator = new Animator(lt);
        animator.start();
        vv.repaint();
    }
}

From source file:org.dita.dost.AbstractIntegrationTest.java

/**
 * Run test conversion/*from w w w.  ja  v a 2 s.  co  m*/
 *
 * @param srcDir    test source directory
 * @param transtype transtype to test
 * @return list of log messages
 * @throws Exception if conversion failed
 */
private List<TestListener.Message> runOt(final File srcDir, final Transtype transtype, final File tempBaseDir,
        final File resBaseDir, final Map<String, String> args, final String[] targets) throws Exception {
    final File tempDir = new File(tempBaseDir, transtype.toString());
    final File resDir = new File(resBaseDir, transtype.toString());
    deleteDirectory(resDir);
    deleteDirectory(tempDir);

    final TestListener listener = new TestListener(System.out, System.err);
    final PrintStream savedErr = System.err;
    final PrintStream savedOut = System.out;
    try {
        final File buildFile = new File(ditaDir, "build.xml");
        final Project project = new Project();
        project.addBuildListener(listener);
        System.setOut(new PrintStream(new DemuxOutputStream(project, false)));
        System.setErr(new PrintStream(new DemuxOutputStream(project, true)));
        project.fireBuildStarted();
        project.init();
        project.setUserProperty("transtype", transtype.name);
        if (transtype.equals("pdf") || transtype.equals("pdf2")) {
            project.setUserProperty("pdf.formatter", "fop");
            project.setUserProperty("fop.formatter.output-format", "text/plain");
        }
        project.setUserProperty("generate-debug-attributes", "false");
        project.setUserProperty("preprocess.copy-generated-files.skip", "true");
        project.setUserProperty("ant.file", buildFile.getAbsolutePath());
        project.setUserProperty("ant.file.type", "file");
        project.setUserProperty("dita.dir", ditaDir.getAbsolutePath());
        project.setUserProperty("output.dir", resDir.getAbsolutePath());
        project.setUserProperty("dita.temp.dir", tempDir.getAbsolutePath());
        project.setUserProperty("clean.temp", "no");
        args.entrySet().forEach(e -> project.setUserProperty(e.getKey(), e.getValue()));

        project.setKeepGoingMode(false);
        ProjectHelper.configureProject(project, buildFile);
        final Vector<String> ts = new Vector<>();
        if (targets != null) {
            ts.addAll(Arrays.asList(targets));
        } else {
            ts.addAll(Arrays.asList(transtype.targets));
        }
        project.executeTargets(ts);

        return listener.messages;
    } finally {
        System.setOut(savedOut);
        System.setErr(savedErr);
    }
}

From source file:org.opencms.flex.CmsFlexRequest.java

/**
 * Return the names of all defined request attributes for this request.<p>
 * //from ww w  . ja  v a 2  s  . co m
 * @return the names of all defined request attributes for this request
 * 
 * @see javax.servlet.ServletRequest#getAttributeNames
 */
@Override
public Enumeration<String> getAttributeNames() {

    Vector<String> v = new Vector<String>();
    v.addAll(m_attributes.keySet());
    return v.elements();
}