protected PanelElementAbstract createPanelElement(BasicDBObject DBO, int idx) { T t; try { t = clazz.newInstance(); t.setIdx(idx); t.setDisplayer(panelDisplayer); t.setData(DBO); t.initPanel(); PanelElementAbstract b; if (t instanceof ParameterPanel) { b = new PanelElementMono((ParameterPanel) t, this, maxNb > 1 && idx >= minNb, idx); } else { b = new PanelElementPlugin( (ParameterPanelPlugin) t, this, maxNb > 1 && idx >= minNb, enableTest); if (template != null && idx < template.panelElements.size()) ((PanelElementPlugin) b) .setTemplate((PanelElementPlugin) template.panelElements.get(idx)); } // System.out.println("panelElement null:"+(b==null)+ " idx:"+idx+ " "+DBO); return b; } catch (Exception e) { exceptionPrinter.print(e, "", Core.GUIMode); } return null; }
public void process(BufferedImage input) { setInputImage(input); image.reshape(input.getWidth(), input.getHeight()); transform.reshape(input.getWidth(), input.getHeight()); magnitude.reshape(input.getWidth(), input.getHeight()); phase.reshape(input.getWidth(), input.getHeight()); ConvertBufferedImage.convertFrom(input, image, true); fft.forward(image, transform); GDiscreteFourierTransformOps.shiftZeroFrequency(transform, true); GDiscreteFourierTransformOps.magnitude(transform, magnitude); GDiscreteFourierTransformOps.phase(transform, phase); // Convert it to a log scale for visibility GPixelMath.log(magnitude, magnitude); SwingUtilities.invokeLater( new Runnable() { public void run() { setPreferredSize(new Dimension(image.width + 50, image.height + 20)); processedImage = true; } }); doRefreshAll(); }
@NotNull public TIntObjectHashMap<T> preLoadCommitData(@NotNull TIntHashSet commits) throws VcsException { TIntObjectHashMap<T> result = new TIntObjectHashMap<>(); final MultiMap<VirtualFile, String> rootsAndHashes = MultiMap.create(); commits.forEach( commit -> { CommitId commitId = myHashMap.getCommitId(commit); if (commitId != null) { rootsAndHashes.putValue(commitId.getRoot(), commitId.getHash().asString()); } return true; }); for (Map.Entry<VirtualFile, Collection<String>> entry : rootsAndHashes.entrySet()) { VcsLogProvider logProvider = myLogProviders.get(entry.getKey()); if (logProvider != null) { List<? extends T> details = readDetails(logProvider, entry.getKey(), ContainerUtil.newArrayList(entry.getValue())); for (T data : details) { int index = myHashMap.getCommitIndex(data.getId(), data.getRoot()); result.put(index, data); } saveInCache(result); } else { LOG.error( "No log provider for root " + entry.getKey().getPath() + ". All known log providers " + myLogProviders); } } return result; }
private <T extends Enum<T>> String getPropertyValue(T algo) { StringBuilder strb = new StringBuilder(); for (T it : active.algos(algo)) { strb.append(it.name()); strb.append(';'); } return strb.toString(); }
private void initConsoleUI(Process process) { // Init console view myConsoleView = createConsoleView(); myConsoleView.setBorder(new SideBorder(UIUtil.getBorderColor(), SideBorder.LEFT)); myProcessHandler = createProcessHandler(process, myProvider.getCommandLineString()); myConsoleExecuteActionHandler = createConsoleExecuteActionHandler(); ProcessTerminatedListener.attach(myProcessHandler); myProcessHandler.addProcessListener( new ProcessAdapter() { @Override public void processTerminated(ProcessEvent event) { finishConsole(); } }); // Attach to process myConsoleView.attachToProcess(myProcessHandler); // Runner creating final Executor defaultExecutor = ExecutorRegistry.getInstance().getExecutorById(DefaultRunExecutor.EXECUTOR_ID); final DefaultActionGroup toolbarActions = new DefaultActionGroup(); final ActionToolbar actionToolbar = ActionManager.getInstance() .createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false); // Runner creating final JPanel panel = new JPanel(new BorderLayout()); panel.add(actionToolbar.getComponent(), BorderLayout.WEST); panel.add(myConsoleView.getComponent(), BorderLayout.CENTER); actionToolbar.setTargetComponent(panel); final RunContentDescriptor contentDescriptor = new RunContentDescriptor( myConsoleView, myProcessHandler, panel, constructConsoleTitle(myConsoleTitle)); // tool bar actions final List<AnAction> actions = fillToolBarActions(toolbarActions, defaultExecutor, contentDescriptor); registerActionShortcuts(actions, getLanguageConsole().getConsoleEditor().getComponent()); registerActionShortcuts(actions, panel); panel.updateUI(); showConsole(defaultExecutor, contentDescriptor); // Run myProcessHandler.startNotify(); }
/** * Calculate possible hull of a pair of polygons * * @param a * @param b * @return possible hull */ private static EdPolygon calcPHull(EdPolygon aPoly, EdPolygon bPoly) { final boolean db = true; if (db && T.update()) T.msg( "calc possible hull of two polygons" + T.show(aPoly, MyColor.cBLUE, STRK_THICK, -1) + T.show(bPoly, MyColor.cDARKGREEN, STRK_THICK, -1)); PtEntry a = PtEntry.buildFrom(aPoly); PtEntry b = PtEntry.buildFrom(bPoly); PtEntry aHull = PtEntry.convexHull(a); PtEntry bHull = PtEntry.convexHull(b); inf = Inf.create(); if (db && T.update()) { T.msg( "convex hulls" + T.show(aHull.toPolygon(), MyColor.cBLUE, STRK_THICK, -1) + T.show(bHull.toPolygon(), MyColor.cDARKGREEN, STRK_THICK, -1)); } PtEntry ph = hullOfPolygons(a, b, aHull, bHull); traceHullPt = ph; insertValleys(ph, a.source(), b.source()); expandHull(ph, aHull, bHull, true); expandHull(ph, aHull, bHull, false); return ph.toPolygon(); }
public static <T extends BaseEntity> T create(Class<T> baseEntityClass) { T obj = null; try { obj = baseEntityClass.newInstance(); } catch (Exception e) { logger.log(Level.SEVERE, "Instantiating " + baseEntityClass.getName(), e); return (null); } obj.setId(rand.nextInt(5000)); Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); obj.setCreatedDate(cal); obj.setModifiedDate(cal); return (obj); }
@Override public void attachToProcess(ProcessHandler processHandler) { myProcessHandler = processHandler; myPrimaryConsoleView.attachToProcess(processHandler); mySecondaryConsoleView.attachToProcess(processHandler); }
public void paintView() { if (simple != null) simple.fill(MyColor.cLIGHTGRAY); Editor.render(); // T.show(traceHull); COper3.dbPaint(); if (traceHullPt != null) { renderHull(traceHullPt); } T.show(possHull, MyColor.cDARKGREEN, STRK_THICK, -1); T.show(valleyTri, MyColor.cDARKGREEN, STRK_RUBBERBAND, -1); T.show(traceValley, null, -1, -1); T.show(focusPt, MyColor.cRED, -1, MARK_DISC); }
public void process(final BufferedImage buffLeft, final BufferedImage buffRight) { imageLeft.reshape(buffLeft.getWidth(), buffLeft.getHeight()); imageRight.reshape(buffRight.getWidth(), buffRight.getHeight()); grayLeft.reshape(buffLeft.getWidth(), buffLeft.getHeight()); grayRight.reshape(buffRight.getWidth(), buffRight.getHeight()); ConvertBufferedImage.convertFromMulti(buffLeft, imageLeft, true, imageType); ConvertBufferedImage.convertFromMulti(buffRight, imageRight, true, imageType); SwingUtilities.invokeLater( new Runnable() { public void run() { panel.setImages(buffLeft, buffRight); processedImage = true; doRefreshAll(); } }); }
private void scaleUpLayers() { T l = pyramid.getLayer(0); if (upscale == null) { interp = (InterpolatePixelS<T>) FactoryInterpolation.nearestNeighborPixelS(l.getClass()); upscale = (T) l._createNew(l.width, l.height); } else { upscale.reshape(l.width, l.height); } int N = pyramid.getNumLayers(); for (int i = 0; i < N; i++) { new FDistort(pyramid.getLayer(i), upscale).interpNN().scaleExt().apply(); BufferedImage b = ConvertBufferedImage.convertTo(upscale, null, true); if (showScales) addImage(b, String.format("%5.2f", pyramid.getScale(i))); else addImage(b, String.format("%5.2f", pyramid.getSigma(i))); } }
/** * Calc possible hull from a set of polygons * * @param polySet set of polygons * @param first first polygon to include * @param last last polygon to include * @return polygon containing possible hull */ private static EdPolygon calcPHullRange(EdPolygon[] polySet, int first, int last) { final boolean db = true; int len = last + 1 - first; if (len == 1) return polySet[first]; if (len > 2) { if (db && T.update()) { DArray a = new DArray(); for (int i = first; i <= last; i++) a.add(polySet[i]); T.msg("calc possible hull of multiple polygons" + T.show(a, MyColor.cRED, STRK_THICK, -1)); } int n = len / 2; return calcPHull( calcPHullRange(polySet, first, first + n - 1), calcPHullRange(polySet, first + n, last)); } return calcPHull(polySet[first], polySet[first + 1]); }
public static <T> void assertOneOf(T value, T... values) { boolean found = false; for (T v : values) { if (value == v || value != null && value.equals(v)) { found = true; } } Assert.assertTrue(value + " should be equal to one of " + Arrays.toString(values), found); }
public void addStep(@NotNull final T step) { mySteps.add(step); if (step instanceof StepAdapter) { ((StepAdapter) step).registerStepListener(myStepListener); } // card layout is used final Component component = step.getComponent(); if (component != null) { addStepComponent(component); } }
public void release() { for (EditorView<T> view : views) { view.release(); view.removePropertyChangeListener(this); } views.clear(); inputTabs.removeChangeListener(inputTabsChangeListener); inputTabs.removeAll(); inspectorPanel.release(); document.release(); }
/** should be invoked in read action */ private DefaultTreeModel buildModel() { final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(); final Ref<Integer> count = new Ref<Integer>(0); final FactoryMap<MemberChooserObject, ParentNode> map = new FactoryMap<MemberChooserObject, ParentNode>() { @Override protected ParentNode create(final MemberChooserObject key) { ParentNode node = null; DefaultMutableTreeNode parentNode = rootNode; if (supportsNestedContainers() && key instanceof ClassMember) { MemberChooserObject parentNodeDelegate = ((ClassMember) key).getParentNodeDelegate(); if (parentNodeDelegate != null) { parentNode = get(parentNodeDelegate); } } if (isContainerNode(key)) { final ContainerNode containerNode = new ContainerNode(parentNode, key, count); node = containerNode; myContainerNodes.add(containerNode); } if (node == null) { node = new ParentNode(parentNode, key, count); } return node; } }; for (T object : myElements) { final ParentNode parentNode = map.get(object.getParentNodeDelegate()); final MemberNode elementNode = createMemberNode(count, object, parentNode); myNodeToParentMap.put(elementNode, parentNode); myElementToNodeMap.put(object, elementNode); } return new DefaultTreeModel(rootNode); }
public void runAlgorithm() { // traceHull = null; COper3.dbClear(); traceHullPt = null; traceValley = null; simple = null; focusPt = null; possHull = null; valleyTri = null; PtEntry.resetIds(); EdPolygon[] rgn = UHullMain.getPolygons(); if (rgn.length < 2) return; if (C.vb(OLDALG)) { T.disable(); simple = PossHullOper.buildPossibleHull(rgn); T.enable(); } possHull = calcPHullRange(rgn, 0, rgn.length - 1); }
@Override @NotNull protected JComponent createCustomComponent() { new MnemonicHelper().register(getComponent()); myComponent = myComponentFactory.create(); DomUIFactory.getDomUIFactory().setupErrorOutdatingUserActivityWatcher(this, getDomElement()); DomManager.getDomManager(getProject()) .addDomEventListener( new DomEventListener() { @Override public void eventOccured(DomEvent event) { checkIsValid(); } }, this); Disposer.register(this, myComponent); return myComponent.getComponent(); }
public void process(final BufferedImage image) { imageInput.reshape(image.getWidth(), image.getHeight()); imageBinary.reshape(image.getWidth(), image.getHeight()); imageOutput.reshape(image.getWidth(), image.getHeight()); ConvertBufferedImage.convertFromSingle(image, imageInput, imageType); final double threshold = GThresholdImageOps.computeOtsu(imageInput, 0, 255); SwingUtilities.invokeLater( new Runnable() { public void run() { selectThresh.setThreshold((int) threshold); setInputImage(image); selectThresh.getHistogramPanel().update(imageInput); selectThresh.repaint(); } }); doRefreshAll(); }
public DuplexConsoleView( @NotNull S primaryConsoleView, @NotNull T secondaryConsoleView, @Nullable String stateStorageKey) { super(new CardLayout()); myPrimaryConsoleView = primaryConsoleView; mySecondaryConsoleView = secondaryConsoleView; myStateStorageKey = stateStorageKey; add(myPrimaryConsoleView.getComponent(), PRIMARY_CONSOLE_PANEL); add(mySecondaryConsoleView.getComponent(), SECONDARY_CONSOLE_PANEL); mySwitchConsoleAction = new SwitchDuplexConsoleViewAction(); myPrimary = true; enableConsole(getStoredState()); Disposer.register(this, myPrimaryConsoleView); Disposer.register(this, mySecondaryConsoleView); }
@NotNull public static <T extends GradleEntityId> GradleProjectStructureNodeDescriptor<T> buildDescriptor( @NotNull T id, @NotNull String name) { return new GradleProjectStructureNodeDescriptor<T>(id, name, id.getType().getIcon()); }
@Override public void addMessageFilter(Filter filter) { myPrimaryConsoleView.addMessageFilter(filter); mySecondaryConsoleView.addMessageFilter(filter); }
@Override public void printHyperlink(String hyperlinkText, HyperlinkInfo info) { myPrimaryConsoleView.printHyperlink(hyperlinkText, info); mySecondaryConsoleView.printHyperlink(hyperlinkText, info); }
@Override public boolean hasDeferredOutput() { return myPrimaryConsoleView.hasDeferredOutput() && mySecondaryConsoleView.hasDeferredOutput(); }
@Override public void setHelpId(String helpId) { myPrimaryConsoleView.setHelpId(helpId); mySecondaryConsoleView.setHelpId(helpId); }
@Override public void setOutputPaused(boolean value) { myPrimaryConsoleView.setOutputPaused(value); mySecondaryConsoleView.setOutputPaused(value); }
private void construct(EdDisc a, EdDisc b) { this.discA = a; this.discB = b; if (EdDisc.partiallyDisjoint(a, b)) { // if (!UHullMain.oldBitanMethod()) { final boolean db = false; if (a.getRadius() == b.getRadius()) { FPoint2 oa = a.getOrigin(), ob = b.getOrigin(); FPoint2 n = new FPoint2(-(ob.y - oa.y), ob.x - oa.x); n.normalize(); n.x *= a.getRadius(); n.y *= a.getRadius(); seg = new DirSeg(FPoint2.add(oa, n, null), FPoint2.add(ob, n, null)); return; } boolean swap = a.getRadius() > b.getRadius(); if (swap) { b = (EdDisc) discA; a = (EdDisc) discB; } if (db && T.update()) T.msg( "BiTangent construct, arad=" + Tools.f(a.getRadius()) + " brad=" + Tools.f(b.getRadius()) + " swap=" + swap + " origin.a=" + T.show(a.getOrigin())); FPoint2 oa = a.getOrigin(); FPoint2 ob = b.getOrigin(); double U = ob.x, V = ob.y; double A = oa.x - U, B = oa.y - V; double R1 = a.getRadius(); double R2 = b.getRadius(); double S = R2 - R1; double x1, y1, x2, y2; x1 = A; y1 = B; boolean secondRoot; boolean altSlope = Math.abs(B) < Math.abs(A); if (!altSlope) { double C1 = S * S / B, C2 = -A / B; double qA = 1 + C2 * C2, qB = 2 * C1 * C2, qC = C1 * C1 - S * S; double root = Math.sqrt(qB * qB - 4 * qA * qC); x2 = (-qB - root) / (2 * qA); y2 = C1 + C2 * x2; secondRoot = MyMath.sideOfLine(x2, y2, A, B, 0, 0) < 0; if (swap ^ secondRoot) { x2 = (-qB + root) / (2 * qA); y2 = C1 + C2 * x2; } } else { double C1 = S * S / A, C2 = -B / A; double qA = 1 + C2 * C2, qB = 2 * C1 * C2, qC = C1 * C1 - S * S; double root = Math.sqrt(qB * qB - 4 * qA * qC); y2 = (-qB - root) / (2 * qA); x2 = C1 + C2 * y2; secondRoot = MyMath.sideOfLine(x2, y2, A, B, 0, 0) < 0; if (swap ^ secondRoot) { y2 = (-qB + root) / (2 * qA); x2 = C1 + C2 * y2; } } // now grow both discs back to r1, r2 double tx = U; double ty = V; // if (S == 0) { // FPoint2 unit = new FPoint2(-A, -B); // if (swap) { // unit.x = -unit.x; // unit.y = -unit.y; // } // unit.normalize(); // tx += -unit.y * R1; // ty += unit.x * R1; // } else { double F = R1 / S; tx += x2 * F; ty += y2 * F; } if (db && T.update()) T.msg("adding offset to both points: " + tx + ", " + ty + T.show(new FPoint2(tx, ty))); x1 += tx; y1 += ty; x2 += tx; y2 += ty; FPoint2 p1 = new FPoint2(x1, y1); FPoint2 p2 = new FPoint2(x2, y2); if (swap) { FPoint2 tmp = p1; p1 = p2; p2 = tmp; } seg = new DirSeg(p1, p2); if (db && T.update()) T.msg( "swap=" + swap + " altSlope=" + altSlope + " secondRoot=" + secondRoot + " dirseg=" + EdSegment.showDirected(p1, p2)); } // else { // // double th = calcTheta(a, b); // LineEqn eqn = new LineEqn(a.polarPoint(th + Math.PI / 2), th); // double ta = eqn.parameterFor(a.getOrigin()); // double tb = eqn.parameterFor(b.getOrigin()); // seg = new DirSeg(eqn.pt(ta), eqn.pt(tb)); // // } } }
@Override public void scrollTo(int offset) { myPrimaryConsoleView.scrollTo(offset); mySecondaryConsoleView.scrollTo(offset); }
@Override public void clear() { myPrimaryConsoleView.clear(); mySecondaryConsoleView.clear(); }
@Override public void print(@NotNull String s, @NotNull ConsoleViewContentType contentType) { myPrimaryConsoleView.print(s, contentType); mySecondaryConsoleView.print(s, contentType); }