List of usage examples for java.util Vector addAll
public boolean addAll(Collection<? extends E> c)
From source file:it.classhidra.core.controller.bsController.java
public static Vector getActionStreams(String id_action) { Vector _streams = null; info_action iActionMapped = (info_action) getAction_config().get_actions().get(id_action); if (iActionMapped == null) return new Vector(); else if (iActionMapped.getVm_streams() != null) _streams = iActionMapped.getVm_streams(); else {/* w w w . j ava 2 s. co m*/ _streams = new Vector(); Vector _streams_orig = (Vector) getAction_config().get_streams_apply_to_actions().get("*"); if (_streams_orig != null) _streams.addAll(_streams_orig); Vector _streams4action = (Vector) getAction_config().get_streams_apply_to_actions().get(id_action); if (_streams4action != null) { Vector _4add = new Vector(); HashMap _4remove = new HashMap(); for (int i = 0; i < _streams4action.size(); i++) { info_stream currentis = (info_stream) _streams4action.get(i); if (currentis.get_apply_to_action() != null) { info_apply_to_action currentiata = (info_apply_to_action) currentis.get_apply_to_action() .get(id_action); if (currentiata.getExcluded() != null && currentiata.getExcluded().equalsIgnoreCase("true")) _4remove.put(currentis.getName(), currentis.getName()); else _4add.add(currentis); } } _streams.addAll(_4add); if (_4remove.size() > 0) { int i = 0; while (i < _streams.size()) { info_stream currentis = (info_stream) _streams.get(i); if (_4remove.get(currentis.getName()) != null) _streams.remove(i); else i++; } } _streams = new util_sort().sort(_streams, "int_order", "A"); } iActionMapped.setVm_streams(_streams); } return _streams; }
From source file:org.kepler.objectmanager.repository.EcogridRepository.java
/** * Search the repository and return an iterator of EcogridRepositoryResults. * /*from w ww .j av a 2 s. c o m*/ * @see EcogridRepositoryResults * @param queryString * a string to search for * @param authenticate * boolean * @return null if there are no results for the query. An iterator of * EcogridRepositoryResults if there are results. * @throws AuthenticationException */ public Iterator<EcogridRepositoryResults> search(String queryString, boolean authenticate) throws RepositoryException, AuthenticationException { if (isDebugging) { log.debug("search(\"" + queryString + "\")"); } Vector<EcogridRepositoryResults> resultsVector = new Vector<EcogridRepositoryResults>(); //System.out.println("EcogridRepository search(queryString,"+authenticate+") querying with queryString:" + // queryString); ResultsetType rst = arbitrarySearch(buildQueryDoc(queryString), authenticate); if (rst == null) { // check to see if the resultsettype is null return null; } ResultsetTypeRecord[] records = rst.getRecord(); if (records == null || records.length == 0) { // check to see if there are records return null; } if (isDebugging) { log.debug("There are " + records.length + " records"); } // create the EcogridRepositoryResult object and put it in the // vector for (int i = 0; i < records.length; i++) { try { // catch this here so one result can't hose the whole // resultset List<EcogridRepositoryResults> results = EcogridRepositoryResults .parseKarXml(records[i].getIdentifier(), name, i, authenticate); resultsVector.addAll(results); } catch (Exception e) { System.out .println("could not load result: " + records[i].toString() + " error: " + e.getMessage()); } // ResultsetTypeRecord currentRecord = records[i]; } return resultsVector.iterator(); }
From source file:org.apache.ws.security.handler.WSHandler.java
/** * Performs all defined security actions to set-up the SOAP request. * /*from w w w. ja v a 2 s . c om*/ * * @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 between methods * @param actions a vector holding the actions to do in the order defined * in the deployment file or property * @throws WSSecurityException */ protected void doSenderAction(int doAction, Document doc, RequestData reqData, Vector actions, boolean isRequest) throws WSSecurityException { boolean mu = decodeMustUnderstand(reqData); WSSConfig wssConfig = reqData.getWssConfig(); if (wssConfig == null) { wssConfig = secEngine.getWssConfig(); } boolean enableSigConf = decodeEnableSignatureConfirmation(reqData); wssConfig.setEnableSignatureConfirmation(enableSigConf || ((doAction & WSConstants.SC) != 0)); wssConfig.setPasswordsAreEncoded(decodeUseEncodedPasswords(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 may need 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 response 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 = (String) getProperty(reqData.getMsgContext(), WSHandlerConstants.SIG_CONF_DONE); if (!DONE.equals(done) && (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). */ 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: case WSConstants.ENCR: case WSConstants.SIGN: 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; // // Handle any "custom" actions, similarly, // but to preserve behavior from previous // versions, consume (but log) action lookup failures. // default: Action doit = null; try { doit = wssConfig.getAction(actionToDo); } catch (final WSSecurityException e) { log.warn("Error trying to locate a custom action (" + actionToDo + ")", e); } if (doit != null) { doit.execute(this, actionToDo, doc, reqData); } } } /* * 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 && reqData.getSignatureValues().size() > 0) { Vector sigv = (Vector) getProperty(reqData.getMsgContext(), WSHandlerConstants.SEND_SIGV); if (sigv == null) { sigv = new Vector(); setProperty(reqData.getMsgContext(), WSHandlerConstants.SEND_SIGV, sigv); } // sigv.add(reqData.getSignatureValues()); sigv.addAll(reqData.getSignatureValues()); } }
From source file:org.jopac2.jbal.iso2709.Unimarc.java
@Override public void addAuthorsFromTitle() throws JOpac2Exception { Tag t = getFirstTag("200"); // prende tag titolo Vector<Field> v = new Vector<Field>(); // vettore contenente le responsabilita' Field f = t.getField("f"); // prima responsabilita' if (f != null) { // se non c' la prima responsabilita', non puo' averne altre v.add(f);// ww w . j a v a 2s.c o m v.addAll(t.getFields("g")); // responsabilita' successive for (int i = 0; i < v.size(); i++) addAuthor(v.elementAt(i).getContent()); // imposta gli autori } }
From source file:org.unitime.timetable.model.Solution.java
public void createDivSecNumbers(org.hibernate.Session hibSession, Vector messages) { Vector assignments = new Vector(getAssignments()); assignments.addAll(new SolutionDAO().getSession() .createQuery("select distinct c from Class_ c, Solution s inner join s.owner.departments d " + "where s.uniqueId = :solutionId and c.managingDept=d and " + "c.uniqueId not in (select a.clazz.uniqueId from s.assignments a)") .setLong("solutionId", getUniqueId().longValue()).list()); HashSet relatedOfferings = new HashSet(); for (Enumeration e = assignments.elements(); e.hasMoreElements();) { Object o = e.nextElement(); Assignment assignment = (o instanceof Assignment ? (Assignment) o : null); Class_ clazz = (assignment == null ? (Class_) o : assignment.getClazz()); relatedOfferings.add(clazz.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalOffering()); }/* w w w . ja v a 2 s.c o m*/ for (Iterator i = relatedOfferings.iterator(); i.hasNext();) { InstructionalOffering io = (InstructionalOffering) i.next(); for (Iterator j = io.getInstrOfferingConfigs().iterator(); j.hasNext();) { InstrOfferingConfig ioc = (InstrOfferingConfig) j.next(); for (Iterator k = ioc.getSchedulingSubparts().iterator(); k.hasNext();) { SchedulingSubpart subpart = (SchedulingSubpart) k.next(); for (Iterator l = subpart.getClasses().iterator(); l.hasNext();) { Class_ clazz = (Class_) l.next(); if (clazz.getClassSuffix() != null && !getOwner().getDepartments().contains(clazz.getManagingDept())) { Assignment assignment = clazz.getCommittedAssignment(); assignments.add(assignment == null ? (Object) clazz : (Object) assignment); clazz.setClassSuffix(null); } } } } } DivSecAssignmentComparator cmp = new DivSecAssignmentComparator(this, true, false); Collections.sort(assignments, cmp); Assignment lastAssignment = null; SchedulingSubpart lastSubpart = null; Class_ lastClazz = null; int divNum = 1, secNum = 0; HashSet takenDivNums = null; HashSet recompute = new HashSet(); for (Enumeration e = assignments.elements(); e.hasMoreElements();) { Object o = e.nextElement(); Assignment assignment = (o instanceof Assignment ? (Assignment) o : null); Class_ clazz = (assignment == null ? (Class_) o : assignment.getClazz()); if (clazz.getParentClass() != null && clazz.getSchedulingSubpart().getItype() .equals(clazz.getParentClass().getSchedulingSubpart().getItype())) continue; if (lastSubpart == null || !lastSubpart.equals(clazz.getSchedulingSubpart())) { takenDivNums = takenDivisionNumbers(clazz.getSchedulingSubpart()); lastAssignment = null; lastSubpart = null; lastClazz = null; } int nrClasses = clazz.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalOffering() .getNrClasses(clazz.getSchedulingSubpart().getItype()); if (lastAssignment != null && assignment != null) { if (nrClasses >= 100 && cmp.compareTimeLocations(lastAssignment.getClazz(), assignment.getClazz(), lastAssignment.getTimeLocation(), assignment.getTimeLocation()) == 0) { if (lastClazz != null && clazz.getParentClass() != null && !clazz.getParentClass().equals(lastClazz.getParentClass()) && clazz.getParentClass().getDivSecNumber() != null && lastClazz.getParentClass().getDivSecNumber() != null) { if (cmp.compareTimeLocations(lastAssignment.getClazz(), assignment.getClazz(), lastAssignment.getTimeLocation(), assignment.getTimeLocation()) == 0 && clazz.getParentClass().getDivSecNumber().substring(0, 3) .equals(lastClazz.getParentClass().getDivSecNumber().substring(0, 3))) { secNum++; } else { divNum++; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } } else { secNum++; } } else { divNum++; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } } else if (lastClazz != null) { divNum++; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } else { divNum = 1; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } if (divNum == 100 && secNum == 1) { sLog.warn("Division number exceeded 99 for scheduling subpart " + clazz.getSchedulingSubpart().getSchedulingSubpartLabel() + "."); for (Iterator i = clazz.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalOffering() .getInstrOfferingConfigs().iterator(); i.hasNext();) { InstrOfferingConfig cfg = (InstrOfferingConfig) i.next(); for (Iterator j = cfg.getSchedulingSubparts().iterator(); j.hasNext();) { SchedulingSubpart subpart = (SchedulingSubpart) j.next(); if (subpart.getItype().equals(clazz.getSchedulingSubpart().getItype())) recompute.add(subpart); } } } clazz.setClassSuffix(sSufixFormat.format(divNum) + sSufixFormat.format(secNum)); hibSession.update(clazz); lastAssignment = assignment; lastSubpart = clazz.getSchedulingSubpart(); lastClazz = clazz; } if (!recompute.isEmpty()) { HashSet recompute2 = new HashSet(); for (Iterator i = assignments.iterator(); i.hasNext();) { Object o = i.next(); Assignment assignment = (o instanceof Assignment ? (Assignment) o : null); Class_ clazz = (assignment == null ? (Class_) o : assignment.getClazz()); if (recompute.contains(clazz.getSchedulingSubpart())) { clazz.setClassSuffix(null); hibSession.update(clazz); } else { i.remove(); } } cmp = new DivSecAssignmentComparator(this, false, false); Collections.sort(assignments, cmp); lastAssignment = null; lastSubpart = null; lastClazz = null; for (Enumeration e = assignments.elements(); e.hasMoreElements();) { Object o = e.nextElement(); Assignment assignment = (o instanceof Assignment ? (Assignment) o : null); Class_ clazz = (assignment == null ? (Class_) o : assignment.getClazz()); if (lastSubpart == null || !lastSubpart.equals(clazz.getSchedulingSubpart())) { takenDivNums = takenDivisionNumbers(clazz.getSchedulingSubpart()); lastAssignment = null; lastSubpart = null; lastClazz = null; } if (lastAssignment != null && assignment != null) { if (cmp.compareTimeLocations(lastAssignment.getClazz(), assignment.getClazz(), lastAssignment.getTimeLocation(), assignment.getTimeLocation()) == 0) { secNum++; } else { divNum++; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } } else if (lastClazz != null) { divNum++; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } else { divNum = 1; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } if (divNum == 100 && secNum == 1) { sLog.warn("Division number still (fallback) exceeded 99 for scheduling subpart " + clazz.getSchedulingSubpart().getSchedulingSubpartLabel() + "."); for (Iterator i = clazz.getSchedulingSubpart().getInstrOfferingConfig() .getInstructionalOffering().getInstrOfferingConfigs().iterator(); i.hasNext();) { InstrOfferingConfig cfg = (InstrOfferingConfig) i.next(); for (Iterator j = cfg.getSchedulingSubparts().iterator(); j.hasNext();) { SchedulingSubpart subpart = (SchedulingSubpart) j.next(); if (subpart.getItype().equals(clazz.getSchedulingSubpart().getItype())) recompute2.add(subpart); } } } clazz.setClassSuffix(sSufixFormat.format(divNum) + sSufixFormat.format(secNum)); hibSession.update(clazz); lastAssignment = assignment; lastSubpart = clazz.getSchedulingSubpart(); lastClazz = clazz; } if (!recompute2.isEmpty()) { for (Iterator i = assignments.iterator(); i.hasNext();) { Object o = i.next(); Assignment assignment = (o instanceof Assignment ? (Assignment) o : null); Class_ clazz = (assignment == null ? (Class_) o : assignment.getClazz()); if (recompute2.contains(clazz.getSchedulingSubpart())) { clazz.setClassSuffix(null); hibSession.update(clazz); } else { i.remove(); } } cmp = new DivSecAssignmentComparator(this, false, true); Collections.sort(assignments, cmp); lastAssignment = null; lastSubpart = null; lastClazz = null; for (Enumeration e = assignments.elements(); e.hasMoreElements();) { Object o = e.nextElement(); Assignment assignment = (o instanceof Assignment ? (Assignment) o : null); Class_ clazz = (assignment == null ? (Class_) o : assignment.getClazz()); if (lastSubpart == null || cmp.compareSchedulingSubparts(lastSubpart, clazz.getSchedulingSubpart()) != 0) { takenDivNums = takenDivisionNumbers(clazz.getSchedulingSubpart()); lastAssignment = null; lastSubpart = null; lastClazz = null; } if (lastAssignment != null && assignment != null) { if (cmp.compareTimeLocations(lastAssignment.getClazz(), assignment.getClazz(), lastAssignment.getTimeLocation(), assignment.getTimeLocation()) == 0) { secNum++; } else { divNum++; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } } else if (lastClazz != null) { divNum++; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } else { divNum = 1; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } if (divNum == 100 && secNum == 1) { messages.add("Division number exceeded 99 for scheduling subpart " + clazz.getSchedulingSubpart().getSchedulingSubpartLabel() + "."); sLog.warn("Division number still (fallback2) exceeded 99 for scheduling subpart " + clazz.getSchedulingSubpart().getSchedulingSubpartLabel() + "."); } clazz.setClassSuffix(sSufixFormat.format(divNum) + sSufixFormat.format(secNum)); hibSession.update(clazz); lastAssignment = assignment; lastSubpart = clazz.getSchedulingSubpart(); lastClazz = clazz; } } } /* lastSubpart = null; TreeSet otherClasses = new TreeSet(new ClassComparator(ClassComparator.COMPARE_BY_HIERARCHY)); otherClasses.addAll(new SolutionDAO().getSession().createQuery( "select distinct c from Class_ c, Solution s inner join s.owner.departments d "+ "where s.uniqueId = :solutionId and c.managingDept=d and "+ "c.uniqueId not in (select a.clazz.uniqueId from s.assignments a) order by c.schedulingSubpart.uniqueId, c.sectionNumberCache"). setLong("solutionId", getUniqueId().longValue()). list()); for (Iterator i=otherClasses.iterator();i.hasNext();) { Class_ clazz = (Class_)i.next(); if (clazz.getParentClass()!=null && clazz.getSchedulingSubpart().getItype().equals(clazz.getParentClass().getSchedulingSubpart().getItype())) continue; if (clazz.getClassSuffix()!=null) { sLog.warn("This is odd, class "+clazz.getClassLabel()+" already has a div-sec number "+clazz.getClassSuffix()+"."); continue; } if (lastSubpart==null || !lastSubpart.equals(clazz.getSchedulingSubpart())) { takenDivNums = takenDivisionNumbers(clazz.getSchedulingSubpart()); } divNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; if (divNum==100) { messages.add("Division number exceeded 99 for scheduling subpart "+clazz.getSchedulingSubpart().getSchedulingSubpartLabel()+"."); } clazz.setClassSuffix(sSufixFormat.format(divNum)+sSufixFormat.format(1)); takenDivNums.add(new Integer(divNum)); lastSubpart = clazz.getSchedulingSubpart(); hibSession.update(clazz); } */ }
From source file:org.commoncrawl.service.crawler.CrawlLog.java
public Vector<Long> getActiveSegmentIdList() { Vector<Long> segmentIdList = new Vector<Long>(); segmentIdList.addAll(_loggers.keySet()); return segmentIdList; }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java
protected void viewSetSelected() { selectedViewSet = null;//from www .j a v a2 s .c o m selectedView = null; selectedViewDef = null; selectedAltView = null; ((DefaultTreeModel) tree.getModel()).setRoot(null); DefaultListModel model; model = (DefaultListModel) altViewsList.getModel(); model.clear(); model = (DefaultListModel) viewDefsList.getModel(); model.clear(); model = (DefaultListModel) viewsList.getModel(); model.clear(); int inx = viewSetsList.getSelectedIndex(); if (inx > -1) { selectedViewSet = (ViewSet) viewSetVector.get(inx); viewControlPanel.getAddBtn().setEnabled(true); viewDefControlPanel.getAddBtn().setEnabled(true); Vector<String> names = new Vector<String>(selectedViewSet.getViews().keySet()); Collections.sort(names); for (String viewName : names) { model.addElement(viewName); } model = (DefaultListModel) viewDefsList.getModel(); names.clear(); names.addAll(selectedViewSet.getViewDefs().keySet()); Collections.sort(names); for (String viewDefName : names) { model.addElement(viewDefName); } } else { viewControlPanel.getAddBtn().setEnabled(false); viewDefControlPanel.getAddBtn().setEnabled(false); } }
From source file:org.agnitas.beans.impl.MailingImpl.java
@Override public boolean buildDependencies(boolean scanDynTags, List<String> dynNamesForDeletion, ApplicationContext con) throws Exception { Vector<String> dynTags = new Vector<String>(); Vector<String> components = new Vector<String>(); Vector<String> links = new Vector<String>(); // scan for Dyntags // in template-components and Mediatype-Params if (scanDynTags) { dynTags.addAll(this.findDynTagsInTemplates(con)); dynTags.addAll(this.findDynTagsInTemplates(this.getEmailParam().getSubject(), con)); dynTags.addAll(this.findDynTagsInTemplates(this.getEmailParam().getReplyAdr(), con)); dynTags.addAll(this.findDynTagsInTemplates(this.getEmailParam().getFromAdr(), con)); List<String> dynNamesList = this.cleanupDynTags(dynTags); if (dynNamesForDeletion != null) dynNamesForDeletion.addAll(dynNamesList); }//from w w w.j a v a 2 s. c o m // scan for Components // in template-components and dyncontent components.addAll(this.scanForComponents(con)); this.cleanupMailingComponents(components); // scan for Links // in template-components and dyncontent links.addAll(this.scanForLinks(con)); // if(AgnUtils.isOracleDB()) { // causes problem with links in OpenEMM this.cleanupTrackableLinks(links); // } return true; }
From source file:org.agnitas.beans.impl.MailingImpl.java
public Vector<String> findDynTagsInTemplates(ApplicationContext con) throws Exception { Vector<String> addedTags = new Vector<String>(); MailingComponent tmpComp = null;//from w w w. j a v a 2s.co m searchPos = 0; Iterator<MailingComponent> it = this.components.values().iterator(); while (it.hasNext()) { tmpComp = it.next(); if (tmpComp.getType() == MailingComponent.TYPE_TEMPLATE) { addedTags.addAll(this.findDynTagsInTemplates(tmpComp.getEmmBlock(), con)); } } return addedTags; }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.JFreeChartPlotEngine.java
/** * Creates a new JFreeChart {@link Plot} from {@link PlotConfiguration} of this Plotter2D. */// ww w . j a va 2 s. c o m private Plot createPlot() throws ChartPlottimeException { PlotConfiguration currentPlotConfigurationClone = plotInstance.getCurrentPlotConfigurationClone(); List<RangeAxisConfig> rangeAxes = currentPlotConfigurationClone.getRangeAxisConfigs(); Plot plot = null; // Select item placement on domain axis ValueType domainAxisType = currentPlotConfigurationClone.getDomainConfigManager().getValueType(); // create plot and domain axis if (domainAxisType == ValueType.NOMINAL) { CategoryPlot categoryPlot = new LinkAndBrushCategoryPlot(); categoryPlot.setDomainAxis(ChartAxisFactory.createCategoryDomainAxis(currentPlotConfigurationClone)); categoryPlot.setOrientation(currentPlotConfigurationClone.getOrientation()); plot = categoryPlot; } else if (domainAxisType == ValueType.NUMERICAL) { LinkAndBrushXYPlot xyPlot = new LinkAndBrushXYPlot(); xyPlot.setDomainAxis(ChartAxisFactory.createNumericalDomainAxis(plotInstance)); xyPlot.setOrientation(currentPlotConfigurationClone.getOrientation()); plot = xyPlot; } else if (domainAxisType == ValueType.DATE_TIME) { XYPlot xyPlot = new LinkAndBrushXYPlot(); xyPlot.setDomainAxis(ChartAxisFactory.createDateDomainAxis(plotInstance)); xyPlot.setOrientation(currentPlotConfigurationClone.getOrientation()); plot = xyPlot; } else if (domainAxisType == ValueType.INVALID) { throw new ChartPlottimeException("illegal_domain_type", domainAxisType); } else if (domainAxisType == ValueType.UNKNOWN && currentPlotConfigurationClone.getAllValueSources().isEmpty()) { throw new ChartPlottimeException("no_value_source_defined"); } else if (domainAxisType == ValueType.UNKNOWN) { throw new ChartPlottimeException("unknown_dimension_value_type"); } else { throw new RuntimeException( "Item placement is neither categorical, date or numerical. This cannot happen."); } int rangeAxisIdx = 0; for (RangeAxisConfig rangeAxisConfig : rangeAxes) { List<ValueSource> valueSources = rangeAxisConfig.getValueSources(); for (ValueSource valueSource : valueSources) { // prepare call to recursivelyGetSeries Vector<PlotDimension> dimensionVector = new Vector<PlotDimension>(); dimensionVector.addAll(currentPlotConfigurationClone.getDefaultDimensionConfigs().keySet()); // create plot if (domainAxisType == ValueType.NOMINAL) { if (!valueSource.isUsingRelativeIndicator()) { throw new ChartPlottimeException("absolute_indicator_but_nominal_domain", valueSource.getLabel()); } CategoryPlot categoryPlot = (CategoryPlot) plot; addDataAndRendererToCategoryPlot(valueSource, categoryPlot, rangeAxisIdx); } else if (domainAxisType == ValueType.NUMERICAL) { XYPlot xyPlot = (XYPlot) plot; addDataAndRendererToXYPlot(valueSource, xyPlot, rangeAxisIdx); } else if (domainAxisType == ValueType.DATE_TIME) { XYPlot xyPlot = (XYPlot) plot; addDataAndRendererToXYPlot(valueSource, xyPlot, rangeAxisIdx); } else { throw new RuntimeException( "Item placement is neither categorical nor numerical. This cannot happen."); } } // set range axis ValueAxis rangeAxis = ChartAxisFactory.createRangeAxis(rangeAxisConfig, plotInstance); if (rangeAxis != null) { if (domainAxisType == ValueType.NUMERICAL || domainAxisType == ValueType.DATE_TIME) { try { XYPlot xyPlot = (XYPlot) plot; xyPlot.setRangeAxis(rangeAxisIdx, rangeAxis); } catch (RuntimeException e) { // probably this is because the domain axis contains // values less then zero and the scaling is logarithmic. // The shitty JFreeChart implementation does not throw a // proper exception stating what happened, // but just a RuntimeException with a string, so this is // our best guess: if (isProbablyZeroValuesOnLogScaleException(e)) { String label = rangeAxisConfig.getLabel(); if (label == null) { label = I18N.getGUILabel("plotter.unnamed_value_label"); } throw new ChartPlottimeException("gui.plotter.error.log_axis_contains_zero", label); } else { throw e; } } } else if (domainAxisType == ValueType.NOMINAL) { // TODO ensure that all values sources have the same range CategoryPlot categoryPlot = (CategoryPlot) plot; categoryPlot.setRangeAxis(rangeAxisIdx, rangeAxis); } else { throw new RuntimeException( "illegal value type on domain axis - this should not happen because of the checks above."); } } ++rangeAxisIdx; } return plot; }