@SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testConvertOneBDD() { String var1 = "sensor1"; Term s1 = new LiteralTerm<>(var1); ANDTerm and = new ANDTerm(); and.add(s1); Predicate p1[] = { new EqualPredicate<>(var1) }; Predicate<String> p = new AllPredicate<String>(p1); BDDTTRFSimulative<String> ttrf = new BDDTTRFSimulative<>(provider); int samples = 10; SampledReliabilityFunction function = (SampledReliabilityFunction) ttrf.convert(and, new TestTransformer(), p, samples); for (int i = 0; i < samples; i++) { Assert.assertEquals(0.0, function.getSamples().get(i), 1.0E-5); } }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testConvertToBDDExistsPredicate() { String var1 = "sensor1"; String var2 = "sensor2"; Term s1 = new LiteralTerm<>(var1); Term s2 = new LiteralTerm<>(var2); ANDTerm and = new ANDTerm(); and.add(s1, s2); BDDTTRF<String> ttrf = new BDDTTRF<>(provider); Predicate p2[] = { new EqualPredicate<>(var2) }; Predicate<String> p = new AllPredicate<String>(p2); BDD<String> result = ttrf.convertToBDD(and, p); BDD<String> ref = provider.get(var1); Assert.assertEquals(result, ref); }
private boolean collectScoringSortOrderAndTraitInstanceByKey( Map<Integer, Integer> ssoByTraitId, Map<String, TraitInstance> tiByKey) { try { Predicate<TraitInstance> visitor = new Predicate<TraitInstance>() { @Override public boolean evaluate(TraitInstance ti) { tiByKey.put(makeTiKey(ti), ti); if (! ssoByTraitId.containsKey(ti.getTraitId())) { int scoringSortOrder = ti.getScoringSortOrder(); ssoByTraitId.put(ti.getTraitId(), scoringSortOrder); } return true; } }; kdxploreDatabase.getKDXploreKSmartDatabase().visitTraitInstancesForTrial(trial.getTrialId(), WithTraitOption.ONLY_NON_CALC_TRAITS, visitor); } catch (IOException e1) { MsgBox.error(AddScoringSetDialog.this, e1.getMessage(), getTitle()); return false; } return true; }
@Override public void visitTraitInstancesForTrial(int trialId, boolean withTraits, Predicate<TraitInstance> traitInstanceVisitor) throws IOException { WithTraitOption withTraitOption = withTraits ? WithTraitOption.ALL_WITH_TRAITS : WithTraitOption.ALL_WITHOUT_TRAITS; Predicate<TraitInstance> visitor = new Predicate<TraitInstance>() { @Override public boolean evaluate(TraitInstance ti) { Boolean result = Boolean.TRUE; if (traitIds.contains(ti.getTraitId())) { result = traitInstanceVisitor.evaluate(ti); } return result; } }; kdsmartDatabase.visitTraitInstancesForTrial(trialId, withTraitOption, visitor); }
public Map<Plot,Map<Integer,KdxSample>> getEditStateSamplesByPlot(TraitInstance ti, Predicate<Plot> plotFilter) { Map<Plot,Map<Integer,KdxSample>> result = new HashMap<>(plots.size()); for (Plot plot : plots) { if (plotFilter == null || plotFilter.evaluate(plot)) { for (Integer psnum : plot.getSpecimenNumbers(PlotOrSpecimen.INCLUDE_PLOT)) { PlotOrSpecimen pos = plot.getPlotOrSpecimen(psnum); KdxSample sm = getEditStateSampleFor(ti, pos); if (sm != null) { Map<Integer, KdxSample> map = result.get(plot); if (map == null) { map = new HashMap<>(); result.put(plot, map); } map.put(psnum, sm); } } } } return result; }
/** <p>Filters a graph removing those edges whose weight is equal to {@code Double.MAX_VALUE}, or whose capacity is below a certain threshold.</p> * * <p><b>Important</b>: Returned graph is not backed in the input one, so changes will not be reflected on it. * * @param <V> Class type for vertices * @param <E> Class type for edges * @param graph Graph representing the network * @param nev Object responsible for returning weights for edges * @param edgeSpareCapacityTransformer Object responsible for returning capacity for edges (if null, it will not applied) * @param requiredCapacity Capacity threshold. Edges whose capacity is below that value it will be removed * @return Filtered graph */ public static <V, E> Graph<V, E> filterGraph(Graph<V, E> graph, final Transformer<E, Double> nev, final Transformer<E, Double> edgeSpareCapacityTransformer, final double requiredCapacity) { EdgePredicateFilter<V, E> linkFilter = new EdgePredicateFilter<V, E>(new Predicate<E>() { @Override public boolean evaluate(E edge) { if (nev != null && nev.transform(edge) == Double.MAX_VALUE) return false; else if (edgeSpareCapacityTransformer != null && edgeSpareCapacityTransformer.transform(edge) < requiredCapacity) return false; return true; } }); return linkFilter.transform(graph); }
public static <V, E> Graph<V, E> filter(Graph<V, E> graph, final Collection<V> vertices) { Predicate<V> predicate = new Predicate<V>() { @Override public boolean evaluate(V vertex) { if(vertices.contains(vertex)) return true; return false; } }; //Filter graph Filter<V, E> verticesFilter = new VertexPredicateFilter<V, E>(predicate); graph = verticesFilter.transform(graph); return graph; }
/** * Validate the predicates to ensure that all is well. * * @param predicates the predicates to validate * @return predicate array */ static <T> Predicate<? super T>[] validate(Collection<Predicate<? super T>> predicates) { if (predicates == null) { throw new IllegalArgumentException("The predicate collection must not be null"); } if (predicates.size() < 2) { throw new IllegalArgumentException("At least 2 predicates must be specified in the predicate collection, size was " + predicates.size()); } // convert to array like this to guarantee iterator() ordering Predicate<? super T>[] preds = new Predicate[predicates.size()]; int i = 0; for (Iterator<Predicate<? super T>> it = predicates.iterator(); it.hasNext();) { preds[i] = it.next(); if (preds[i] == null) { throw new IllegalArgumentException("The predicate collection must not contain a null predicate, index " + i + " was null"); } i++; } return preds; }
public static <V> Graph<V, WeightedEdge> filter(final Graph<V, WeightedEdge> graph, final int degree) { Predicate<V> predicate = new Predicate<V>() { @Override public boolean evaluate(V vertex) { Collection<WeightedEdge> incidentEdges = graph.getIncidentEdges(vertex); if(incidentEdges.size() > degree) { return true; } return false; } }; //Filter graph Filter<V, WeightedEdge> verticesFilter = new VertexPredicateFilter<V, WeightedEdge>(predicate); return verticesFilter.transform(graph); }
public static <V> Graph<V, WeightedEdge> filter(Graph<V, WeightedEdge> graph, final double weight) { Predicate<WeightedEdge> edgePredicate = new Predicate<WeightedEdge>() { @Override public boolean evaluate(WeightedEdge edge) { if(edge.getWeight() > weight) return true; return false; } }; //Filter graph Filter<V, WeightedEdge> edgeFiler = new EdgePredicateFilter<V, WeightedEdge>(edgePredicate); graph = edgeFiler.transform(graph); return graph; }
/** * Returns a {@link BDD} representing the given {@link Term} while respecting the exists-variables. * * @param term * the term * @param existsPredicate * the exists predicate * @return a bdd representing the given term */ public BDD<T> convertToBDD(Term term, Predicate<T> existsPredicate) { BDD<T> bdd = transform(term); if (!(existsPredicate == null)) { Set<T> variables = Terms.getVariables(term); for (T variable : variables) { if (existsPredicate.evaluate(variable)) { BDD<T> tmp = bdd.exist(variable); bdd.free(); bdd = tmp; } } } return bdd; }
private SampleGroup createSampleGroupAndCollectTraitInstances(DeviceIdentifier scoringDevId, Map<Integer, Integer> ssoByTraitId, Map<String, TraitInstance> tiByKey, List<TraitInstance> traitInstances) { // int maxSso = 0; // if (! ssoByTraitId.isEmpty()) { // List<Integer> ssos = new ArrayList<>(ssoByTraitId.values()); // ssos.sort(Comparator.reverseOrder()); // maxSso = ssos.get(0); // } SampleGroup sampleGroup = new SampleGroup(); sampleGroup.setDateLoaded(new Date()); sampleGroup.setDeviceIdentifierId(scoringDevId.getDeviceIdentifierId()); sampleGroup.setOperatorName(descriptionField.getText().trim()); sampleGroup.setTrialId(trial.getTrialId()); // Now need to create the samples - but first - need all the TraitInstances java.util.function.Predicate<TraitInstance> visitor = new java.util.function.Predicate<TraitInstance>() { @Override public boolean test(TraitInstance ti) { traitInstances.add(ti); return true; } }; traitInstanceChoiceTreeModel.visitChosenChildNodes(visitor); return sampleGroup; }
private List<Specimen> getSpecimens(KDSmartDatabase db) throws IOException { final List<Specimen> specimens = new ArrayList<>(); Predicate<Specimen> visitor = new Predicate<Specimen>() { @Override public boolean evaluate(Specimen s) { specimens.add(s); return true; } }; db.visitSpecimensForTrial(trial.getEntityId(), visitor); return specimens; }
public Map<PlotOrSpecimen,KdxSample> getEditStateSamplesByPlotOrSpecimen(TraitInstance ti, Predicate<Plot> plotFilter) { Map<PlotOrSpecimen,KdxSample> result = new HashMap<>(plots.size()); for (Plot plot : plots) { if (plotFilter == null || plotFilter.evaluate(plot)) { for (Integer psnum : plot.getSpecimenNumbers(PlotOrSpecimen.INCLUDE_PLOT)) { PlotOrSpecimen pos = plot.getPlotOrSpecimen(psnum); KdxSample sm = getEditStateSampleFor(ti, pos); if (sm != null) { result.put(pos, sm); } } } } return result; }
protected List<Integer> collectColumnIndices(Predicate<ValueRetriever<?>> predicate) { List<Integer> result = new ArrayList<>(); for (int vfIndex = valueRetrievers.size(); --vfIndex >= 0; ) { ValueRetriever<?> vr = valueRetrievers.get(vfIndex); if (predicate.evaluate(vr)) { result.add(vfIndex); } } return result; }
/** * Returns a FilterIterator that blocks * all of its elements * * @param i the Iterator to "filter" * @return "filtered" iterator */ protected FilterIterator makeBlockAllFilter(Iterator i) { Predicate pred = new Predicate() { public boolean evaluate(Object x) { return false; } }; return new FilterIterator(i, pred); }
/** * Constructor that wraps (not copies). * * @param map the map to decorate, must not be null * @param keyPredicate the predicate to validate the keys, null means no check * @param valuePredicate the predicate to validate to values, null means no check * @throws IllegalArgumentException if the map is null */ protected PredicatedMap(Map<K, V> map, Predicate<? super K> keyPredicate, Predicate<? super V> valuePredicate) { super(map); this.keyPredicate = keyPredicate; this.valuePredicate = valuePredicate; Iterator<Map.Entry<K, V>> it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry<K, V> entry = it.next(); K key = entry.getKey(); V value = entry.getValue(); validate(key, value); } }
/** * Factory method that performs validation. * * @param predicate predicate to switch on * @param trueClosure closure used if true * @param falseClosure closure used if false * @return the <code>if</code> closure * @throws IllegalArgumentException if any argument is null */ public static <T> Closure<T> getInstance(Predicate<? super T> predicate, Closure<? super T> trueClosure, Closure<? super T> falseClosure) { if (predicate == null) { throw new IllegalArgumentException("Predicate must not be null"); } if (trueClosure == null || falseClosure == null) { throw new IllegalArgumentException("Closures must not be null"); } return new IfClosure<T>(predicate, trueClosure, falseClosure); }
/** * Validate the predicates to ensure that all is well. * * @param predicates the predicates to validate */ static <T> void validate(Predicate<? super T>[] predicates) { if (predicates == null) { throw new IllegalArgumentException("The predicate array must not be null"); } for (int i = 0; i < predicates.length; i++) { if (predicates[i] == null) { throw new IllegalArgumentException("The predicate array must not contain a null predicate, index " + i + " was null"); } } }
/** * Validate the predicates to ensure that all is well. * * @param predicates the predicates to validate */ static <T> void validateMin2(Predicate<? super T>[] predicates) { if (predicates == null) { throw new IllegalArgumentException("The predicate array must not be null"); } if (predicates.length < 2) { throw new IllegalArgumentException("At least 2 predicates must be specified in the predicate array, size was " + predicates.length); } for (int i = 0; i < predicates.length; i++) { if (predicates[i] == null) { throw new IllegalArgumentException("The predicate array must not contain a null predicate, index " + i + " was null"); } } }
/** * Factory method that performs validation and copies the parameter arrays. * * @param predicates array of predicates, cloned, no nulls * @param transformers matching array of transformers, cloned, no nulls * @param defaultTransformer the transformer to use if no match, null means nop * @return the <code>chained</code> transformer * @throws IllegalArgumentException if array is null * @throws IllegalArgumentException if any element in the array is null */ public static <I,O> Transformer<I, O> getInstance(Predicate<? super I>[] predicates, Transformer<? super I, ? extends O>[] transformers, Transformer<? super I, ? extends O> defaultTransformer) { FunctorUtils.validate(predicates); FunctorUtils.validate(transformers); if (predicates.length != transformers.length) { throw new IllegalArgumentException("The predicate and transformer arrays must be the same size"); } if (predicates.length == 0) { return (defaultTransformer == null ? ConstantTransformer.NULL_INSTANCE : defaultTransformer); } predicates = FunctorUtils.copy(predicates); transformers = FunctorUtils.copy(transformers); return new SwitchTransformer<I, O>(predicates, transformers, defaultTransformer); }
/** * Returns a FilterIterator that does not filter * any of its elements * * @param i the Iterator to "filter" * @return "filtered" iterator */ protected FilterIterator makePassThroughFilter(Iterator i) { Predicate pred = new Predicate() { public boolean evaluate(Object x) { return true; } }; return new FilterIterator(i, pred); }
/** * Factory method that performs validation. * * @param predicate the predicate used to evaluate when the loop terminates, not null * @param closure the closure the execute, not null * @param doLoop true to act as a do-while loop, always executing the closure once * @return the <code>while</code> closure * @throws IllegalArgumentException if the predicate or closure is null */ public static <T> Closure<T> getInstance(Predicate<? super T> predicate, Closure<? super T> closure, boolean doLoop) { if (predicate == null) { throw new IllegalArgumentException("Predicate must not be null"); } if (closure == null) { throw new IllegalArgumentException("Closure must not be null"); } return new WhileClosure<T>(predicate, closure, doLoop); }
/** * Factory method that performs validation and copies the parameter arrays. * * @param predicates array of predicates, cloned, no nulls * @param closures matching array of closures, cloned, no nulls * @param defaultClosure the closure to use if no match, null means nop * @return the <code>chained</code> closure * @throws IllegalArgumentException if array is null * @throws IllegalArgumentException if any element in the array is null */ public static <T> Closure<T> getInstance(Predicate<? super T>[] predicates, Closure<? super T>[] closures, Closure<? super T> defaultClosure) { FunctorUtils.validate(predicates); FunctorUtils.validate(closures); if (predicates.length != closures.length) { throw new IllegalArgumentException("The predicate and closure arrays must be the same size"); } if (predicates.length == 0) { return (defaultClosure == null ? NOPClosure.INSTANCE : defaultClosure); } predicates = FunctorUtils.copy(predicates); closures = FunctorUtils.copy(closures); return new SwitchClosure<T>(predicates, closures, defaultClosure); }
private void verifyElementsInPredicate(final String[] elements) { Predicate pred = new Predicate() { public boolean evaluate(Object x) { for (int i = 0; i < elements.length; i++) if (elements[i].equals(x)) return true; return false; } }; initIterator(); iterator.setPredicate(pred); for (int i = 0; i < elements.length; i++) { String s = (String) iterator.next(); assertEquals(elements[i], s); assertTrue(i == elements.length - 1 ? !iterator.hasNext() : iterator.hasNext()); } verifyNoMoreElements(); // test removal initIterator(); iterator.setPredicate(pred); if (iterator.hasNext()) { Object last = iterator.next(); iterator.remove(); assertTrue("Base of FilterIterator still contains removed element.", !list.contains(last)); } }
protected Predicate stringPredicate() { return new Predicate() { public boolean evaluate(Object o) { return o instanceof String; } }; }
public GraphFilter(Predicate<SubstrateNode> nodePredicate, Predicate<SubstrateLink> linkPredicate) { this.nodePredicate = nodePredicate; this.linkPredicate = linkPredicate; }
@Override public ReliabilityFunction convert(Term term, Transformer<T, ReliabilityFunction> functionTransformer, Predicate<T> existsPredicate) { BDD<T> bdd = convertToBDD(term, existsPredicate); return convert(bdd, functionTransformer); }
@Override public ReliabilityFunction convert(Term term, Transformer<T, ReliabilityFunction> functionTransformer, Predicate<T> existsPredicate) { List<Double> samples = collectTimesToFailure(term, functionTransformer, existsPredicate); return new SampledReliabilityFunction(samples); }
@Override public void visitSpecimensForTrial(int trialId, Predicate<Specimen> visitor) throws IOException { kdsmartDatabase.visitSpecimensForTrial(trialId, visitor); }
public void initialise() { plotInfoByPlotId.clear(); try { KDSmartDatabase.WithPlotAttributesOption wpa = KDSmartDatabase.WithPlotAttributesOption.WITHOUT_PLOT_ATTRIBUTES; Map<Integer,Plot> plotById = kdxdb.getPlots(trial, SampleGroupChoice.create(sampleGroup.getSampleGroupId()), wpa) .stream() .collect(Collectors.toMap(Plot::getPlotId, java.util.function.Function.identity())); traitById = kdxdb.getKDXploreKSmartDatabase().getTraitMap(); KDSmartDatabase.WithTraitOption wto = KDSmartDatabase.WithTraitOption.ALL_WITH_TRAITS; Predicate<TraitInstance> tiVisitor = new Predicate<TraitInstance>() { @Override public boolean evaluate(TraitInstance ti) { String key = makeTiKey(ti.getTraitId(), ti.getInstanceNumber()); tiByKey.put(key, ti); return true; } }; kdxdb.getKDXploreKSmartDatabase().visitTraitInstancesForTrial(trial.getTrialId(), wto, tiVisitor); Set<Integer> traitIdsSeen = new HashSet<>(); // sampleGroup.getTrialId(); java.util.function.Predicate<KdxSample> visitor = new java.util.function.Predicate<KdxSample>() { @Override public boolean test(KdxSample s) { Plot plot = plotById.get(s.getPlotId()); if (plot == null) { System.err.println("Missing Plot#" + s.getPlotId()); } else { PlotInfo pinfo = plotInfoByPlotId.get(plot.getPlotId()); if (pinfo == null) { pinfo = new PlotInfo(plot); plotInfoByPlotId.put(plot.getPlotId(), pinfo); } Integer traitId = s.getTraitId(); traitIdsSeen.add(traitId); pinfo.addSample(s); } return true; } }; boolean scored = false; kdxdb.visitKdxSamplesForSampleGroup( sampleGroup, KdxploreDatabase.SampleLevel.BOTH, scored, visitor); } catch (IOException e) { MsgBox.error(SampleGroupViewer.this, e, "Database Error"); return; } }
private String getBriefSummary(SampleGroup sampleGroup) throws IOException { Bag<Integer> plotIdsWithSpecimens = new HashBag<>(); Set<Integer> plotIdsWithScores = new HashSet<>(); int[] results = new int[3]; java.util.function.Predicate<KdxSample> visitor = new java.util.function.Predicate<KdxSample>() { @Override public boolean test(KdxSample s) { plotIdsWithScores.add(s.getPlotId()); int snum = s.getSpecimenNumber(); if (snum <= 0) { ++results[0]; // Plot level sample count } else { ++results[1]; // Individual level sample count plotIdsWithSpecimens.add(s.getPlotId()); results[2] = Math.max(results[2], snum); // maximum specimen number } return true; } }; boolean scored = true; kdxdb.visitKdxSamplesForSampleGroup( sampleGroup, KdxploreDatabase.SampleLevel.BOTH, scored, visitor); int nPlotSamples = results[0]; int nSpecimenSamples = results[1]; int totalScoredSamples = nPlotSamples + nSpecimenSamples; int maxSpecimenNumber = results[2]; int nPlotsWithSpecimens = plotIdsWithSpecimens.size(); int nPlotsWithScores = plotIdsWithScores.size(); int maxCount = 0; for (Integer plotId : plotIdsWithSpecimens.uniqueSet()) { int count = plotIdsWithSpecimens.getCount(plotId); maxCount = Math.max(maxCount, count); } StringBuilder sb = new StringBuilder("<HTML>"); sb.append("<br><B>Scored Samples:</b> ").append(totalScoredSamples); sb.append("<br><B>Plot Level Samples:</b> ").append(nPlotSamples); sb.append("<br><B>Individual Samples:</b> ").append(nSpecimenSamples); sb.append("<br>"); sb.append("<br><B>Max Individual number:</b> ").append(maxSpecimenNumber); sb.append("<br><B># Plots with Individuals:</b> ").append(nPlotsWithSpecimens); sb.append("<br>"); sb.append("<br><B># Plots with scored samples:</b> ").append(nPlotsWithScores); sb.append("<br><B>Max # individual scores per plot:</b> ").append(maxCount); return sb.toString(); }
private void refreshTrialTableModel(KdxploreDatabase kdxdb) { //TODO ListSelectionModel Everywhere in this file Manil // ListSelectionModel lsm = trialTreeTableModel.getSelectionModel(); try { // lsm.setValueIsAdjusting(true); // trialsTable.clearSelection(); if (kdxdb == null ) { kdxdb = offlineData.getKdxploreDatabase(); } Map<Trial, List<SampleGroup>> trialsAndSampleGroups = kdxdb.getTrialsAndSampleGroups(KdxploreDatabase.WithSamplesOption.WITHOUT_SAMPLES); trialTableModel.setTrialsAndSampleGroups(trialsAndSampleGroups); KDSmartDatabase kdsdb = kdxdb.getKDXploreKSmartDatabase(); Map<Trial,Map<Trait,Integer>> traitSsoByTrial = new HashMap<>(); for (Trial trial : trialsAndSampleGroups.keySet()) { Predicate<TraitInstance> traitInstanceVisitor = new Predicate<TraitInstance>() { @Override public boolean evaluate(TraitInstance ti) { Map<Trait,Integer> map = traitSsoByTrial.get(trial); if (map == null) { map = new HashMap<>(); traitSsoByTrial.put(trial, map); } map.put(ti.trait, ti.getScoringSortOrder()); return Boolean.TRUE; } }; kdsdb.visitTraitInstancesForTrial(trial.getTrialId(), WithTraitOption.ALL_WITH_TRAITS, traitInstanceVisitor); } trialTraitsTableModel.setTraitsByTrial(traitSsoByTrial); } catch (IOException e) { MsgBox.error(TrialOverviewPanel.this, e.getMessage(), "Problem Getting Trials"); } finally { // lsm.clearSelection(); // // int modelRow = trialTreeTableModel.indexOfTrial(selectedTrial); // if (modelRow >= 0) { // int viewRow = trialTreeTableModel.convertRowIndexToView(modelRow); // if (viewRow >= 0) { // lsm.setSelectionInterval(viewRow, viewRow); // } // } } // // lsm.setValueIsAdjusting(false); }
public Map<Plot,Map<Integer,KdxSample>> getEditStateSamplesByPlot(TraitInstance ti, Predicate<Plot> plotFilter) { return curationData.getEditStateSamplesByPlot(ti, plotFilter); }
public Map<PlotOrSpecimen,KdxSample> getEditStateSamplesByPlotOrSpecimen(TraitInstance ti, Predicate<Plot> plotFilter) { return curationData.getEditStateSamplesByPlotOrSpecimen(ti, plotFilter); }
@SuppressWarnings({ "rawtypes", "unchecked" }) public static void render(Node tree) { // Grafo Factory<DirectedGraph<Node, Integer>> factory = DirectedOrderedSparseMultigraph .<Node, Integer> getFactory(); graph = new DelegateTree<Node, Integer>(factory); // Adiciona os v�rtices ao grafo graph.addVertex(tree); build(tree); // Layout TreeLayout<Node, Integer> layout = new TreeLayout<Node, Integer>(graph, 75, 50); // Visualiza��o VisualizationViewer<Node, Integer> vv = new VisualizationViewer<Node, Integer>( layout); VertexLabelAsShapeRenderer<Node, Integer> vlasr = new VertexLabelAsShapeRenderer<Node, Integer>( vv.getRenderContext()); /* V�rtices */ // Cor da borda vv.getRenderContext().setVertexDrawPaintTransformer( new ConstantTransformer(Color.black)); // Cor de fundo vv.getRenderContext().setVertexFillPaintTransformer( new ConstantTransformer(Color.lightGray)); // R�tulo como string vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); // Formato retangular vv.getRenderContext().setVertexShapeTransformer(vlasr); // Posiciona texto dentro vv.getRenderer().setVertexLabelRenderer(vlasr); /* Arestas */ // Remove a seta da aresta vv.getRenderContext().setEdgeArrowPredicate( new Predicate<Context<Graph<Node, Integer>, Integer>>() { @Override public boolean evaluate( Context<Graph<Node, Integer>, Integer> arg0) { return false; } }); // Formato da linha vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); // Habilita suporte ao mouse final DefaultModalGraphMouse<Node, Integer> graphMouse = new DefaultModalGraphMouse<Node, Integer>(); vv.setGraphMouse(graphMouse); // Cria a janela do JFrame JFrame jf = new JFrame(); jf.getContentPane().add(vv); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setTitle("Abstract Syntax Tree"); jf.pack(); jf.setExtendedState(JFrame.MAXIMIZED_BOTH); jf.setVisible(true); }
protected Collection decorateCollection(Collection collection, Predicate predicate) { return PredicatedCollection.decorate(collection, predicate); }
protected Buffer decorateBuffer(Buffer buffer, Predicate predicate) { return PredicatedBuffer.decorate(buffer, predicate); }
protected SortedMap decorateMap(SortedMap map, Predicate keyPredicate, Predicate valuePredicate) { return PredicatedSortedMap.decorate(map, keyPredicate, valuePredicate); }