Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
272,500 | String () { return "gold_LinePainter2D"; } | getGoldenImageName |
272,501 | Dimension () { return new Dimension((LINE_LEN * 2 + 2) * 4 + 2, LINE_LEN * 2 + 4); } | getImageSize |
272,502 | int[] () { return new int[] {1, 2, 3}; } | getScales |
272,503 | void () { super.testGoldenImages(); } | testGoldenImages |
272,504 | void () { ImageComparator comparator = new ImageComparator(); /* * In fact, absolute accuracy is achieved by painting with enabled antialiasing, in which case alpha more precisely * shows sub-pixel offsets. However, in that case outlining the right/bottom rect edge would bring additional * complexity to calculating the outline x/y. This is likely an overkill. So, in this test the only scale factors * which allow to achieve pixel-perfect accuracy are counted (more precisely, the combination of factor and coordinates). * The test thus represents a defacto behaviour. */ // IDE-HiDPI for (double scale : new double[]{1, 1.25, /*1.5,*/ 1.75, 2, 2.25, 2.5, /*2.75,*/ 3}) { testRectOutline(comparator, scale, false, StrokeType.CENTERED); if (scale == 2.5) continue; testRectOutline(comparator, scale, false, StrokeType.INSIDE); } // JRE-HiDPI for (double scale : new double[]{1, 1.25, /*1.5,*/ 1.75, 2, 2.25, /*2.5,*/ 2.75, 3}) { testRectOutline(comparator, scale, true, StrokeType.CENTERED); testRectOutline(comparator, scale, true, StrokeType.INSIDE); } } | testRectOutlining |
272,505 | Void (Graphics2D g) { paintRects(g, StrokeType.CENTERED, 2, 2); paintRects(g, StrokeType.INSIDE, RECT_SIZE + 2, 0); paintRects(g, StrokeType.OUTSIDE, RECT_SIZE + 2, 0); return null; } | paint |
272,506 | void (Graphics2D g, StrokeType type, float trX, float trY) { g.translate(JBUIScale.scale(trX), JBUIScale.scale(trY)); Object aa = RenderingHints.VALUE_ANTIALIAS_ON; paintRect(g, 0, 0, RECT_SIZE, RECT_SIZE, null, type, 1, aa, false); paintRect(g, 0, RECT_SIZE + 3, RECT_SIZE, RECT_SIZE, ARC_SIZE, type, 1, aa, false); paintRect(g, 0, (RECT_SIZE + 3) * 2, RECT_SIZE, RECT_SIZE, null, type, 1, aa, true); paintRect(g, 0, (RECT_SIZE + 3) * 3, RECT_SIZE, RECT_SIZE, ARC_SIZE, type, 1, aa, true); } | paintRects |
272,507 | void (Graphics2D g, double x, double y, double w, double h, Double arc, StrokeType strokeType, double strokeWidth, Object valueAA, boolean fill) { strokeWidth = JBUIScale.scale((float)strokeWidth); if (arc != null) arc = Double.valueOf(JBUIScale.scale(arc.floatValue())); x = JBUIScale.scale((float)x); y = JBUIScale.scale((float)y); w = JBUIScale.scale((float)w); h = JBUIScale.scale((float)h); if (fill) { RectanglePainter2D.FILL.paint(g, x, y, w, h, arc, strokeType, strokeWidth, valueAA); } else { RectanglePainter2D.DRAW.paint(g, x, y, w, h, arc, strokeType, strokeWidth, valueAA); } } | paintRect |
272,508 | void (Graphics2D g, double[] values) { RectanglePainter2D.DRAW.paint(g, values[0], values[1], values[2], values[3]); RectanglePainter2D.FILL.paint(g, values[0], values[1], values[2], values[3]); } | paintBoundaries |
272,509 | void (ImageComparator comparator, double scale, boolean jreHiDPIEnabled, StrokeType strokeType) { overrideJreHiDPIEnabled(jreHiDPIEnabled); float scale1 = jreHiDPIEnabled ? 1 : (float)scale; JBUIScale.setUserScaleFactor(scale1); BufferedImage rect = supplyGraphics(scale, 15, 15, strokeType == StrokeType.INSIDE ? RectanglePainter2DTest::paintRectInside : RectanglePainter2DTest::paintRectCentered); BufferedImage outline = supplyGraphics(scale, 15, 15, strokeType == StrokeType.INSIDE ? RectanglePainter2DTest::outlineRectInside : RectanglePainter2DTest::outlineRectCentered); compare(rect, outline, comparator, scale); } | testRectOutline |
272,510 | Rectangle2D (Graphics2D g) { double x = PaintUtil.alignToInt(JBUIScale.scale(3f), g); double w = PaintUtil.alignToInt(JBUIScale.scale(10f), g); //noinspection SuspiciousNameCombination return new Rectangle2D.Double(x, x, w, w); } | rectBounds |
272,511 | Void (Graphics2D g) { return _paintRect(g, true); } | paintRectInside |
272,512 | Void (Graphics2D g) { return _paintRect(g, false); } | paintRectCentered |
272,513 | Void (Graphics2D g, boolean inside) { Rectangle2D b = rectBounds(g); RectanglePainter2D.DRAW.paint(g, b.getX(), b.getY(), b.getWidth(), b.getHeight(), inside ? StrokeType.INSIDE : StrokeType.CENTERED, JBUIScale.scale(1f)); return null; } | _paintRect |
272,514 | Void (Graphics2D g) { Rectangle2D b = rectBounds(g); double x = b.getX(); double y = b.getY(); double xx = x + b.getWidth(); double yy = y + b.getHeight(); // the rect right/bottom edge is painted at x + width - 1/y + height - 1 (unlike in Graphics.drawRect) double _xx = xx - 1; double _yy = yy - 1; LinePainter2D.paint(g, b.getX(), b.getY(), _xx, b.getY(), StrokeType.INSIDE, JBUIScale.scale(1f)); LinePainter2D.paint(g, xx, b.getY(), xx, _yy, StrokeType.OUTSIDE, JBUIScale.scale(1f)); LinePainter2D.paint(g, _xx, yy, b.getX(), yy, StrokeType.OUTSIDE, JBUIScale.scale(1f)); LinePainter2D.paint(g, b.getX(), _yy, b.getX(), b.getY(), StrokeType.INSIDE, JBUIScale.scale(1f)); return null; } | outlineRectInside |
272,515 | Void (Graphics2D g) { Rectangle2D b = rectBounds(g); double x = b.getX(); double y = b.getY(); double xx = x + b.getWidth(); double yy = y + b.getHeight(); // the rect right/bottom edge is painted at x + width - 1/y + height - 1 (unlike in Graphics.drawRect) xx -= 1; yy -= 1; LinePainter2D.paint(g, b.getX(), b.getY(), xx, b.getY(), StrokeType.CENTERED_CAPS_SQUARE, JBUIScale.scale(1f)); LinePainter2D.paint(g, xx, b.getY(), xx, yy, StrokeType.CENTERED_CAPS_SQUARE, JBUIScale.scale(1f)); LinePainter2D.paint(g, xx, yy, b.getX(), yy, StrokeType.CENTERED_CAPS_SQUARE, JBUIScale.scale(1f)); LinePainter2D.paint(g, b.getX(), yy, b.getX(), b.getY(), StrokeType.CENTERED_CAPS_SQUARE, JBUIScale.scale(1f)); return null; } | outlineRectCentered |
272,516 | String () { return "gold_RectanglePainter2D"; } | getGoldenImageName |
272,517 | Dimension () { return new Dimension((RECT_SIZE + 2) * 3 + 3, (RECT_SIZE + 3) * 4 + 2); } | getImageSize |
272,518 | int[] () { return new int[] {1, 2, 3}; } | getScales |
272,519 | void () { TestScaleHelper.assumeStandalone(); TestScaleHelper.assumeHeadful(); System.setProperty(JAVA2D_UI_SCALE_ENABLED_PROP, "true"); System.setProperty(JAVA2D_UI_SCALE_PROP, "3.0"); assertTrue(JAVA2D_UI_SCALE_ENABLED_PROP + " system property is ignored", JreHiDpiUtil.isJreHiDPIEnabled()); if (!SystemInfoRt.isMac) { assertEquals(JAVA2D_UI_SCALE_PROP + " system property is ignored", 3f, JBUIScale.INSTANCE.computeSystemScaleFactor(() -> null)); } } | test |
272,520 | void () { assumeFalse(SystemInfoRt.isMac); } | before |
272,521 | void () { TestScaleHelper.assumeStandalone(); TestScaleHelper.assumeHeadful(); System.setProperty(JAVA2D_UI_SCALE_ENABLED_PROP, "false"); assertFalse(JAVA2D_UI_SCALE_ENABLED_PROP + " system property is ignored", JreHiDpiUtil.isJreHiDPIEnabled()); } | test |
272,522 | void () { TestScaleHelper.assumeStandalone(); TestScaleHelper.assumeHeadful(); System.setProperty(HIDPI_PROP, "false"); UiKt.checkHiDPISettings(); Graphics2D g = TestScaleHelper.createGraphics(2); Assert.assertFalse(UI_SCALE_PROP + " should be disabled", Boolean.getBoolean(UI_SCALE_PROP)); Assert.assertFalse("hidpi should be disabled", StartupUiUtil.isJreHiDPI()); Assert.assertFalse("hidpi should be disabled", JreHiDpiUtil.isJreHiDPI(g)); } | test |
272,523 | void () { TestScaleHelper.assumeStandalone(); TestScaleHelper.assumeHeadful(); System.setProperty(IDE_UI_SCALE_PROP, "1.0"); JBUIScale.setUserScaleFactor(2f); assertEquals(IDE_UI_SCALE_PROP + " system property is ignored", 1f, JBUIScale.scale(1f)); } | test |
272,524 | void (Graphics g) { super.paintComponent(g); g.setColor(Color.red); final Graphics2D g2d = (Graphics2D)g; int arc1 = 4; int arc2 = 6; final Rectangle r = new Rectangle(arc1, arc1, getWidth() - arc1 - 1, getHeight() - arc1 - 1); myT.reset(r); myT.moveTo(myT.getX() - myT.deltaX(arc1), myT.getMaxY()); myT.quadTo(myT.getX(), myT.getMaxY(), myT.getX(), myT.getMaxY() - myT.deltaY(arc1)); myT.lineTo(myT.getX(), myT.getY() + myT.deltaY(arc2)); myT.quadTo(myT.getX(), myT.getY(), myT.getX() + myT.deltaX(arc2), myT.getY()); myT.lineTo(myT.getMaxX() - myT.deltaX(arc2), myT.getY()); myT.quadTo(myT.getMaxX(), myT.getY(), myT.getMaxX(), myT.getY() + myT.deltaY(arc2)); myT.lineTo(myT.getMaxX(), myT.getMaxY()); g2d.draw(myT.getShape()); final int innerRecSize = 18; final Rectangle innerRec = new Rectangle(getWidth() / 2 - innerRecSize / 2, getHeight() / 2 - innerRecSize / 2, innerRecSize, innerRecSize); final ShapeTransform inner = myT.createTransform(innerRec); inner.moveTo(inner.getX(), inner.getMaxY()); inner.lineTo(inner.getX(), inner.getY()); inner.lineTo(inner.getMaxX(), inner.getY()); inner.lineTo(inner.getMaxX(), inner.getMaxY()); g2d.draw(inner.getShape()); } | paintComponent |
272,525 | void (String[] args) { final JFrame frame = new JFrame(); frame.getContentPane().setLayout(new BorderLayout()); final JPanel content = new JPanel(new FlowLayout(FlowLayout.CENTER)); frame.getContentPane().add(content, BorderLayout.CENTER); content.add(new Painter("TOP", new ShapeTransform.Top())); content.add(new Painter("LEFT", new ShapeTransform.Left())); content.add(new Painter("BOTTOM", new ShapeTransform.Bottom())); content.add(new Painter("RIGHT", new ShapeTransform.Right())); frame.setBounds(300, 300, 300, 300); frame.show(); } | main |
272,526 | void (ActionEvent e) { if (myProgressButton.getText().equals("Start")) { myProgressBar1.setIndeterminate(true); myProgressButton.setText("Stop"); } else { myProgressBar1.setIndeterminate(false); myProgressButton.setText("Start"); } } | actionPerformed |
272,527 | void (ActionEvent e) { myStartButton.setEnabled(false); new Thread("darcula test"){ @Override public void run() { while (myProgressBar2.getValue() < 100) { TimeoutUtil.sleep(20); myProgressBar2.setValue(myProgressBar2.getValue() + 1); } TimeoutUtil.sleep(1000); myProgressBar2.setValue(0); myStartButton.setEnabled(true); } }.start(); } | actionPerformed |
272,528 | void () { while (myProgressBar2.getValue() < 100) { TimeoutUtil.sleep(20); myProgressBar2.setValue(myProgressBar2.getValue() + 1); } TimeoutUtil.sleep(1000); myProgressBar2.setValue(0); myStartButton.setEnabled(true); } | run |
272,529 | void (String[] args) { try { UIManager.setLookAndFeel(new DarculaLaf()); } catch (UnsupportedLookAndFeelException ignored) {} final JFrame frame = new JFrame("Darcula Demo"); frame.setSize(900, 500); final DarculaTest form = new DarculaTest(); final JPanel root = form.myRoot; frame.setContentPane(root); frame.getRootPane().setDefaultButton(form.myDefaultButton); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { @Override public void eventDispatched(AWTEvent event) { if (event instanceof KeyEvent && event.getID() == KeyEvent.KEY_PRESSED && ((KeyEvent)event).getKeyCode() == KeyEvent.VK_F1) { new ShowUIDefaultsAction().perform(null); } } }, AWTEvent.KEY_EVENT_MASK); SwingUtilities.invokeLater(() -> frame.setVisible(true)); } | main |
272,530 | void (AWTEvent event) { if (event instanceof KeyEvent && event.getID() == KeyEvent.KEY_PRESSED && ((KeyEvent)event).getKeyCode() == KeyEvent.VK_F1) { new ShowUIDefaultsAction().perform(null); } } | eventDispatched |
272,531 | void () { JBUIScale.DEF_SYSTEM_FONT_SIZE = 12; overrideJreHiDPIEnabled(false); for (int usrScale : new int[] {1, 2, 3}) { test(ScaleContext.Companion.of(new Scale[]{SYS_SCALE.of(1), USR_SCALE.of(usrScale)})); } overrideJreHiDPIEnabled(true); for (int sysScale : new int[] {1, 2, 3}) { for (int usrScale : new int[] {1, 2, 3}) { test(ScaleContext.Companion.of(new Scale[]{SYS_SCALE.of(sysScale), USR_SCALE.of(usrScale)})); } } } | test |
272,532 | void (ScaleContext ctx) { JBUIScale.setUserScaleFactor((float)ctx.getScale(USR_SCALE)); Font font = StartupUiUtil.getLabelFont().deriveFont(JBUIScale.scale(JBUIScale.DEF_SYSTEM_FONT_SIZE)); Graphics2D g = TestScaleHelper.createGraphics(ctx.getScale(SYS_SCALE)); double actual = EffectPainter2D.maybeScaleFontMetricsThickness_TestOnly(1, font); double expectedHighBound = PaintUtil.alignToInt(JBUIScale.getFontScale(font.getSize2D()), g, RoundingMode.ROUND_FLOOR_BIAS); double expectedLowBound = expectedHighBound / 3; Assert.assertTrue(TestScaleHelper.msg(ctx), actual >= expectedLowBound && actual <= expectedHighBound); } | test |
272,533 | void () { overrideJreHiDPIEnabled(false); testPainter(EffectPainter2D.LINE_UNDERSCORE); overrideJreHiDPIEnabled(true); testPainter(EffectPainter2D.LINE_UNDERSCORE); } | testLineUnderscore |
272,534 | void () { overrideJreHiDPIEnabled(false); testPainter(EffectPainter2D.BOLD_LINE_UNDERSCORE); overrideJreHiDPIEnabled(true); testPainter(EffectPainter2D.BOLD_LINE_UNDERSCORE); } | testBoldLineUnderscore |
272,535 | void () { overrideJreHiDPIEnabled(false); testPainter(EffectPainter2D.BOLD_DOTTED_UNDERSCORE); overrideJreHiDPIEnabled(true); testPainter(EffectPainter2D.BOLD_DOTTED_UNDERSCORE); } | testBoldDottedUnderscore |
272,536 | void () { overrideJreHiDPIEnabled(false); testPainter(EffectPainter2D.WAVE_UNDERSCORE); overrideJreHiDPIEnabled(true); testPainter(EffectPainter2D.WAVE_UNDERSCORE); } | testWaveUnderscore |
272,537 | void () { overrideJreHiDPIEnabled(false); testPainter(EffectPainter2D.STRIKE_THROUGH); overrideJreHiDPIEnabled(true); testPainter(EffectPainter2D.STRIKE_THROUGH); } | testStrikeThrough |
272,538 | void (EffectPainter2D painter) { for (int size : SIZES) testPainter(painter, 100, size); } | testPainter |
272,539 | void (EffectPainter2D painter, int width, int height) { if (painter == EffectPainter2D.STRIKE_THROUGH) height += 10; // default font size testPainter(painter, ImageUtil.createImage(width, height, BufferedImage.TYPE_INT_ARGB)); } | testPainter |
272,540 | void (EffectPainter2D painter, BufferedImage image) { String[] content = createContent(image, painter, 0); testContent(content, content.length / 2, false); for (int size : SIZES) testPartialContent(painter, image, content, size); testPartialContent(painter, image, content, content.length / 2); Assert.assertEquals("unexpected amount of empty columns", painter == EffectPainter2D.BOLD_DOTTED_UNDERSCORE, hasEmpty(content)); Assert.assertTrue("image is not clear if offset too large", isEmpty(createContent(image, painter, content.length))); Assert.assertTrue("image is not clear if nothing to paint", isEmpty(createContent(image, null, 0))); } | testPainter |
272,541 | void (EffectPainter2D painter, BufferedImage image, String[] content, int offset) { String[] partial = createContent(image, painter, offset); int length = content.length; Assert.assertEquals("content size differs", length, partial.length); for (int i = offset; i < length; i++) { Assert.assertEquals("content differs", content[i], partial[i]); } boolean out = painter == EffectPainter2D.BOLD_DOTTED_UNDERSCORE; // may be painted out of area testContent(partial, offset, out ? null : true); } | testPartialContent |
272,542 | String[] (BufferedImage image, EffectPainter2D painter, int offset) { return createContent(image, painter, FOREGROUND, offset); } | createContent |
272,543 | String[] (BufferedImage image, EffectPainter2D painter, Paint foreground, int offset) { int width = image.getWidth(); int height = image.getHeight(); double width2D = width; double height2D = height; double offset2D = offset; // prepare buffers String[] content = new String[width]; char[] chars = new char[height]; if (image instanceof JBHiDPIScaledImage) { double scale = ((JBHiDPIScaledImage)image).getScale(); width2D = width / scale; height2D = height / scale; offset2D = offset / scale; } Graphics2D graphics = image.createGraphics(); // clear image content graphics.setPaint(BACKGROUND); RectanglePainter2D.FILL.paint(graphics, 0, 0, width2D, height2D); if (painter != null) { // paint image content boolean over = painter == EffectPainter2D.STRIKE_THROUGH; // paint over baseline graphics.setPaint(foreground); painter.paint(graphics, offset2D, over ? height2D : 0, width2D - offset2D, height2D, null); } graphics.dispose(); // convert content int bg = BACKGROUND.getRGB(); int fg = FOREGROUND.getRGB(); for (int x = 0; x < content.length; x++) { for (int y = 0; y < chars.length; y++) { int rgb = image.getRGB(x, y); chars[y] = rgb == bg ? ' ' : rgb == fg ? '0' : '.'; } content[x] = new String(chars); } return content; } | createContent |
272,544 | void (String[] content, int offset, Boolean expected) { Assert.assertFalse("unexpected right part (empty background)", isEmpty(content, offset)); if (expected != null) Assert.assertEquals("unexpected left part", expected, isEmpty(content, 0, offset)); } | testContent |
272,545 | boolean (String value) { return value.chars().allMatch(ch -> ch == ' '); } | isEmpty |
272,546 | boolean (String[] content) { return Arrays.stream(content).anyMatch(EffectPainterTest::isEmpty); } | hasEmpty |
272,547 | boolean (String[] content) { return Arrays.stream(content).allMatch(EffectPainterTest::isEmpty); } | isEmpty |
272,548 | boolean (String[] content, int offset) { return Arrays.stream(content, offset, content.length).allMatch(EffectPainterTest::isEmpty); } | isEmpty |
272,549 | boolean (String[] content, int offset, int length) { return Arrays.stream(content, offset, offset + length).allMatch(EffectPainterTest::isEmpty); } | isEmpty |
272,550 | void () { BufferedImage testImg = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB); Color testColor1 = Color.RED; Color testColor2 = Color.BLUE; { Graphics2D g = testImg.createGraphics(); g.setColor(testColor1); g.fillRect(0,0, testImg.getWidth(), testImg.getHeight()); g.setColor(testColor2); g.fillRect(testImg.getWidth() - 2, testImg.getHeight() - 2, 2, 2); } Icon testIcon = new ImageIcon(testImg); ScaleContext ctx = ScaleContext.create(); BufferedImage image; if (GraphicsEnvironment.isHeadless()) { // for testing purpose image = ImageUtil.createImage(ctx, testIcon.getIconWidth(), testIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB, PaintUtil.RoundingMode.ROUND); } else { if (StartupUiUtil.INSTANCE.isJreHiDPI(ctx)) { image = new HiDPIImage(ctx, testIcon.getIconWidth(), testIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB_PRE, PaintUtil.RoundingMode.ROUND); } else { image = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice().getDefaultConfiguration() .createCompatibleImage(PaintUtil.RoundingMode.ROUND.round(ctx.apply(testIcon.getIconWidth(), DerivedScaleType.DEV_SCALE)), PaintUtil.RoundingMode.ROUND.round(ctx.apply(testIcon.getIconHeight(), DerivedScaleType.DEV_SCALE)), Transparency.TRANSLUCENT); } } Graphics2D g = image.createGraphics(); try { testIcon.paintIcon(null, g, 0, 0); } finally { g.dispose(); } Assert.assertEquals(image.getRGB(0, 0), testColor1.getRGB()); Assert.assertEquals(image.getRGB(image.getWidth() - 1, image.getHeight() - 1), testColor2.getRGB()); } | testPaintImage |
272,551 | void () { List<TreePath> list = new ArrayList<>(); Collections.addAll(list, PARENT1, CHILD11, CHILD12, PARENT2, CHILD21, CHILD22); testCollect(list, TreeCollector.TreePathLeafs.collect(list), 4); Collections.reverse(list); testCollect(list, TreeCollector.TreePathLeafs.collect(list), 4); Collections.shuffle(list); testCollect(list, TreeCollector.TreePathLeafs.collect(list), 4); } | testTreePathLeafsCollect |
272,552 | void () { List<TreePath> list = new ArrayList<>(); Collections.addAll(list, PARENT1, CHILD11, CHILD12, PARENT2, CHILD21, CHILD22); testCollect(list, TreeCollector.TreePathRoots.collect(list), 2); Collections.reverse(list); testCollect(list, TreeCollector.TreePathRoots.collect(list), 2); Collections.shuffle(list); testCollect(list, TreeCollector.TreePathRoots.collect(list), 2); } | testTreePathRootsCollect |
272,553 | void () { testCollectDuplicates(TreeCollector.TreePathLeafs.collect( new TreePath("duplicated"), new TreePath("duplicated"), new TreePath("duplicated"))); } | testTreePathLeafsCollectDuplicates |
272,554 | void () { testCollectDuplicates(TreeCollector.TreePathRoots.collect( new TreePath("duplicated"), new TreePath("duplicated"), new TreePath("duplicated"))); } | testTreePathRootsCollectDuplicates |
272,555 | void (List<TreePath> list) { Assert.assertEquals(1, list.size()); } | testCollectDuplicates |
272,556 | void () { testCollectMutable(TreeCollector.TreePathLeafs.collect()); testCollectMutable(TreeCollector.TreePathLeafs.collect(new TreePath(new Object()))); } | testTreePathLeafsCollectMutable |
272,557 | void () { testCollectMutable(TreeCollector.TreePathRoots.collect()); testCollectMutable(TreeCollector.TreePathRoots.collect(new TreePath(new Object()))); } | testTreePathRootsCollectMutable |
272,558 | void (List<TreePath> list) { list.add(new TreePath(new Object())); Assert.assertFalse(list.isEmpty()); list.clear(); Assert.assertTrue(list.isEmpty()); } | testCollectMutable |
272,559 | void () { testCollectNull(TreeCollector.VirtualFileLeafs.collect((VirtualFile)null)); testCollectNull(TreeCollector.VirtualFileLeafs.collect((VirtualFile[])null)); } | testVirtualFileLeafsCollectNull |
272,560 | void () { testCollectNull(TreeCollector.VirtualFileRoots.collect((VirtualFile)null)); testCollectNull(TreeCollector.VirtualFileRoots.collect((VirtualFile[])null)); } | testVirtualFileRootsCollectNull |
272,561 | void () { testCollectNull(TreeCollector.TreePathLeafs.collect((TreePath)null)); testCollectNull(TreeCollector.TreePathLeafs.collect((TreePath[])null)); } | testTreePathLeafsCollectNull |
272,562 | void () { testCollectNull(TreeCollector.TreePathRoots.collect((TreePath)null)); testCollectNull(TreeCollector.TreePathRoots.collect((TreePath[])null)); } | testTreePathRootsCollectNull |
272,563 | void () { testCreate(TreeCollector.VirtualFileLeafs::create); } | testVirtualFileLeafsCreate |
272,564 | void () { testCreate(TreeCollector.VirtualFileRoots::create); } | testVirtualFileRootsCreate |
272,565 | void () { testCreate(TreeCollector.TreePathLeafs::create); } | testTreePathLeafsCreate |
272,566 | void () { testCreate(TreeCollector.TreePathRoots::create); } | testTreePathRootsCreate |
272,567 | void (String[] args) { testPaths(FIND_COMMON_PATH, FAST, 10, 10); testPaths(FIND_COMMON_PATH, FAST, 1, 10); testPaths(FIND_COMMON_PATH, SLOW, 1, 1); testPaths(FIND_COMMON_PATH, SLOW, 1, 2); testPaths(FIND_COMMON_PATH, SLOW, 1, 3); testPaths(FIND_COMMON_PATH, SLOW, 1, 4); testPaths(FIND_COMMON_PATH, SLOW, 1, 5); testPaths(FIND_COMMON_PATH, SLOW, 1, 6); testPaths(FIND_COMMON_PATH, SLOW, 2, 6); testPaths(FIND_COMMON_PATH, SLOW, 3, 6); testPaths(FIND_COMMON_PATH, SLOW, 4, 6); testPaths(FIND_COMMON_PATH, SLOW, 5, 6); testPaths(FIND_COMMON_PATH, SLOW, 6, 6); testPaths(SELECT_MAXIMALS, FAST, 7, 7); testPaths(SELECT_MAXIMALS, FAST, 1, 7); testPaths(SELECT_MAXIMALS, SLOW, 1, 1); testPaths(SELECT_MAXIMALS, SLOW, 1, 2); testPaths(SELECT_MAXIMALS, SLOW, 1, 3); testPaths(SELECT_MAXIMALS, SLOW, 1, 4); testPaths(SELECT_MAXIMALS, SLOW, 2, 4); testPaths(SELECT_MAXIMALS, SLOW, 3, 4); testPaths(SELECT_MAXIMALS, SLOW, 4, 4); } | main |
272,568 | void (IntFunction<Object> function, int min, int max, List<TreePath> list, TreePath path) { if (path == null) path = new TreePath(function.apply(0)); // create path to root node int count = path.getPathCount(); if (min <= count) list.add(path); if (max <= count) return; for (int i = 0; i <= count; i++) { addPaths(function, min, max, list, path.pathByAddingChild(function.apply(i))); } } | addPaths |
272,569 | void (Consumer<TreePath[]> consumer, IntFunction<Object> function, int min, int max) { List<TreePath> list = new ArrayList<>(); addPaths(function, min, max, list, null); System.err.println(); System.err.println(list.size() + " paths with count from " + min + " to " + max); System.err.println("1. ordered list:"); consumer.accept(TreePathUtil.toTreePathArray(list)); Collections.reverse(list); System.err.println("2. reversed list:"); consumer.accept(TreePathUtil.toTreePathArray(list)); Collections.shuffle(list); System.err.println("3. shuffled list:"); consumer.accept(TreePathUtil.toTreePathArray(list)); } | testPaths |
272,570 | void (String method, Runnable runnable) { System.err.printf("%,12d ms to %s%n", TimeoutUtil.measureExecutionTime(runnable::run), method); } | measureExecutionTime |
272,571 | String () { return String.valueOf(id); } | toString |
272,572 | int () { return id; } | hashCode |
272,573 | boolean (Object object) { TimeoutUtil.sleep(1); // simulate slow comparison return object instanceof Slow && ((Slow)object).id == id; } | equals |
272,574 | void (JTree tree, String... expected) { test(tree, true, false, expected); } | testIncrease |
272,575 | void (JTree tree, String... expected) { test(tree, false, true, expected); } | testDecrease |
272,576 | void (JTree tree, String... expected) { test(tree, true, true, expected); } | testIncreaseDecrease |
272,577 | void (JTree tree, boolean increase, boolean decrease, String... expected) { int length = expected.length; if (length < 2) throw new IllegalArgumentException(); if (!increase && !decrease) throw new IllegalArgumentException(); assertTree(tree, expected[0]); if (increase) { for (int i = 1; i < expected.length; i++) { provider.increaseSelection(tree); assertTree(tree, expected[i]); } } if (decrease) { for (int i = 1; i < expected.length; i++) { provider.decreaseSelection(tree); assertTree(tree, expected[increase ? expected.length - 1 - i : i]); } } } | test |
272,578 | void (int row, String expected) { test(tree -> { select(tree, row); testDecrease(tree, expected, expected); }); test(TreeSelectionModel.SINGLE_TREE_SELECTION, tree -> { select(tree, row); testDecrease(tree, expected, expected); }); } | testDecreaseDoNotClearSelection |
272,579 | void () { TestApplicationManager.getInstance(); } | setUp |
272,580 | void () { testDecreaseDoNotClearSelection(10, """ -Root -Color Red Green Blue +Digit -Letter -Greek Alpha Beta [Gamma] Delta Epsilon """); } | testDecreaseFromLeafNode |
272,581 | void () { testDecreaseDoNotClearSelection(5, """ -Root -Color Red Green Blue +[Digit] -Letter -Greek Alpha Beta Gamma Delta Epsilon """); } | testDecreaseFromCollapsedNode |
272,582 | void () { testDecreaseDoNotClearSelection(7, """ -Root -Color Red Green Blue +Digit -Letter -[Greek] Alpha Beta Gamma Delta Epsilon """); } | testDecreaseFromExpandedNode |
272,583 | void () { testDecreaseDoNotClearSelection(6, """ -Root -Color Red Green Blue +Digit -[Letter] -Greek Alpha Beta Gamma Delta Epsilon """); } | testDecreaseFromExpandedParentNode |
272,584 | void () { test(true, tree -> { select(tree, 5); testIncrease(tree, """ -Root -Color Red Green Blue +[Digit] -Letter -Greek Alpha Beta Gamma Delta Epsilon """, // 1 // 1 // 1 // select siblings of node """ -Root -[Color] [Red] [Green] [Blue] +[Digit] -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """, // 2 // 2 // 2 // select visible root """ -[Root] -[Color] [Red] [Green] [Blue] +[Digit] -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """, // 3 // 3 // 3 // do nothing """ -[Root] -[Color] [Red] [Green] [Blue] +[Digit] -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """); }); } | testIncreaseToVisibleRoot |
272,585 | void () { test(false, tree -> { select(tree, 5); testIncrease(tree, """ -Root -Color Red Green Blue +[Digit] -Letter -Greek Alpha Beta Gamma Delta Epsilon """, // 1 // 1 // 1 // select siblings of node """ -Root -[Color] [Red] [Green] [Blue] +[Digit] -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """, // 2 // 2 // 2 // do nothing """ -Root -[Color] [Red] [Green] [Blue] +[Digit] -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """); }); } | testIncreaseToHiddenRoot |
272,586 | void () { test(tree -> { select(tree, 10); testIncreaseDecrease(tree, """ -Root -Color Red Green Blue +Digit -Letter -Greek Alpha Beta [Gamma] Delta Epsilon """, // 1 // 1 // 1 // select siblings of node """ -Root -Color Red Green Blue +Digit -Letter -Greek [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """, // 2 // 2 // 2 // select parent of node """ -Root -Color Red Green Blue +Digit -Letter -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """, // 3 // 3 // 3 // select grand parent of node """ -Root -Color Red Green Blue +Digit -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """, // 4 // 4 // 4 // select siblings of grand parent """ -Root -[Color] [Red] [Green] [Blue] +[Digit] -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """); }); } | testIncreaseDecreaseFromLeafNode |
272,587 | void () { test(tree -> { select(tree, 5); testIncreaseDecrease(tree, """ -Root -Color Red Green Blue +[Digit] -Letter -Greek Alpha Beta Gamma Delta Epsilon """, // 1 // 1 // 1 // select siblings of node """ -Root -[Color] [Red] [Green] [Blue] +[Digit] -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """); }); } | testIncreaseDecreaseFromCollapsedNode |
272,588 | void () { test(tree -> { select(tree, 7); testIncreaseDecrease(tree, """ -Root -Color Red Green Blue +Digit -Letter -[Greek] Alpha Beta Gamma Delta Epsilon """, // 1 // 1 // 1 // select children of node """ -Root -Color Red Green Blue +Digit -Letter -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """, // 2 // 2 // 2 // select parent of node """ -Root -Color Red Green Blue +Digit -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """, // 3 // 3 // 3 // select siblings of parent """ -Root -[Color] [Red] [Green] [Blue] +[Digit] -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """); }); } | testIncreaseDecreaseFromExpandedNode |
272,589 | void () { test(tree -> { select(tree, 6); testIncreaseDecrease(tree, """ -Root -Color Red Green Blue +Digit -[Letter] -Greek Alpha Beta Gamma Delta Epsilon """, // 1 // 1 // 1 // select descendants of node """ -Root -Color Red Green Blue +Digit -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """, // 2 // 2 // 2 // select siblings of node """ -Root -[Color] [Red] [Green] [Blue] +[Digit] -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """); }); } | testIncreaseDecreaseFromExpandedParentNode |
272,590 | void () { test(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION, tree -> { select(tree, 3, 10); testIncreaseDecrease(tree, """ -Root -Color Red [Green] Blue +Digit -Letter -Greek Alpha Beta [Gamma] Delta Epsilon """, // 1 // 1 // 1 // select siblings of second node """ -Root -Color Red [Green] Blue +Digit -Letter -Greek [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """, // 2 // 2 // 2 // select parent of second node """ -Root -Color Red [Green] Blue +Digit -Letter -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """, // 3 // 3 // 3 // grand parent of node """ -Root -Color Red [Green] Blue +Digit -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """); }); } | testIncreaseDecreaseWithoutCapture |
272,591 | void () { test(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION, tree -> { select(tree, 10, 3); testIncrease(tree, """ -Root -Color Red [Green] Blue +Digit -Letter -Greek Alpha Beta [Gamma] Delta Epsilon """, // 1 // 1 // 1 // select siblings of second node """ -Root -Color [Red] [Green] [Blue] +Digit -Letter -Greek Alpha Beta [Gamma] Delta Epsilon """, // 2 // 2 // 2 // select parent of second node """ -Root -[Color] [Red] [Green] [Blue] +Digit -Letter -Greek Alpha Beta [Gamma] Delta Epsilon """, // 3 // 3 // 3 // select siblings of parent """ -Root -[Color] [Red] [Green] [Blue] +[Digit] -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """); testDecrease(tree, """ -Root -[Color] [Red] [Green] [Blue] +[Digit] -[Letter] -[Greek] [Alpha] [Beta] [Gamma] [Delta] [Epsilon] """, // 1 // 1 // 1 // unselect siblings of parent "-Root\n" + " -[Color]\n" + " [Red]\n" + " [Green]\n" + " [Blue]\n" + " +Digit\n" + " -Letter\n" + " -Greek\n" + " Alpha\n" + " Beta\n" + " Gamma\n" + // captured " Delta\n" + " Epsilon\n", // 2 // 2 // 2 // unselect parent of second node "-Root\n" + " -Color\n" + " [Red]\n" + " [Green]\n" + " [Blue]\n" + " +Digit\n" + " -Letter\n" + " -Greek\n" + " Alpha\n" + " Beta\n" + " Gamma\n" + // captured " Delta\n" + " Epsilon\n", // 3 // 3 // 3 // select siblings of second node "-Root\n" + " -Color\n" + " Red\n" + " [Green]\n" + " Blue\n" + " +Digit\n" + " -Letter\n" + " -Greek\n" + " Alpha\n" + " Beta\n" + " Gamma\n" + // captured " Delta\n" + " Epsilon\n"); }); } | testIncreaseDecreaseWithCapture |
272,592 | void () { test(TreeSelectionModel.SINGLE_TREE_SELECTION, tree -> { select(tree, 10); testIncreaseDecrease(tree, """ -Root -Color Red Green Blue +Digit -Letter -Greek Alpha Beta [Gamma] Delta Epsilon """, // 1 // 1 // 1 // do nothing """ -Root -Color Red Green Blue +Digit -Letter -Greek Alpha Beta [Gamma] Delta Epsilon """, // 2 // 2 // 2 // do nothing """ -Root -Color Red Green Blue +Digit -Letter -Greek Alpha Beta [Gamma] Delta Epsilon """); }); } | testSingleTreeSelection |
272,593 | void () { @SuppressWarnings("UndesirableClassUsage") JTree tree = new JTree(new DefaultTreeModel( node("/", node("ktor", node("ktor-core"), node("ktor-features", node("jetty-http-client"), node("ktor-locations", node("src", node("asdsd.asdas.asdas", node("a"), node("b"), node("c"))), node("tests", node("fooo")), node("zar.txt"), node("zoo.txt"))))))); TreeTestUtil.assertTreeUI(tree); expandAll(tree); waitForTestOnEDT(() -> { tree.setSelectionRow(10); Assert.assertEquals(15, tree.getRowCount()); assertTree(tree, """ -/ -ktor ktor-core -ktor-features jetty-http-client -ktor-locations -src -asdsd.asdas.asdas a b [c] -tests fooo zar.txt zoo.txt """); TreeSmartSelectProvider provider = new TreeSmartSelectProvider(); provider.increaseSelection(tree); provider.increaseSelection(tree); provider.increaseSelection(tree); provider.increaseSelection(tree); provider.increaseSelection(tree); assertTree(tree, """ -/ -ktor ktor-core -ktor-features jetty-http-client -[ktor-locations] -[src] -[asdsd.asdas.asdas] [a] [b] [c] -[tests] [fooo] [zar.txt] [zoo.txt] """); }); } | testSelectionDoesntJumpTooQuickly |
272,594 | TreeNode () { return node("Root", node("Color", node("Red"), node("Green"), node("Blue")), node("Digit", node("One"), node("Two"), node("Three"), node("Four"), node("Five"), node("Six"), node("Seven"), node("Eight"), node("Nine")), node("Letter", node("Greek", node("Alpha"), node("Beta"), node("Gamma"), node("Delta"), node("Epsilon")))); } | root |
272,595 | int (JTree tree, int row) { return tree.isRootVisible() ? row : row - 1; } | normalize |
272,596 | void (JTree tree, int... rows) { for (int row : rows) tree.addSelectionRow(normalize(tree, row)); } | select |
272,597 | void (JTree tree, String expected) { String actual = new TreeTestUtil(tree).withSelection().toString(); Assert.assertEquals(expected, !tree.isRootVisible() ? "-Root\n" + actual : actual); } | assertTree |
272,598 | void (Consumer<? super JTree> consumer) { test(true, consumer); test(false, consumer); } | test |
272,599 | void (int selectionMode, Consumer<? super JTree> consumer) { test(selectionMode, true, consumer); test(selectionMode, false, consumer); } | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.