id
stringlengths
36
36
text
stringlengths
1
1.25M
ef0fcd8e-6612-4e84-87d9-2b6bbf689284
public void setSize(int size) { this.size = size; }
20a1a711-076b-4c75-a1a6-2f5669e38964
public int getSize() { return this.size; }
21c7bcc6-7757-4188-89dd-a8a5f77be409
@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getName()); builder.append("\nWeight: ").append(this.getWeight()); builder.append("\nColor: ").append(this.getColor().toString()); builder.append("\nHardness: ").append...
43e1d194-90cf-4f68-8b6c-72086690e066
public Diamond() { this.form = Form.UNDEFINED; this.size = 0; }
2bddb6f2-4a5e-4a89-9b38-35c506d403a8
public Diamond(Form form) { this.form = form; this.size = 0; }
77ca35ff-289c-4a17-8e64-504fbb6eb10f
public Diamond(Form form, int size) { this.form = form; this.size = size; }
0928bce8-7ec7-4ad1-abfd-a3d9b1bb2640
public void setForm(Form form) { this.form = form; }
b1d55d2b-0878-4369-98e7-993175dad02d
public Form getForm() { return this.form; }
1827fd3b-ac55-47f9-b660-d75d3521ba40
public void setSize(int size) { this.size = size; }
123f8d03-353d-46b5-ba80-ac942fd3207d
public int getSize() { return this.size; }
98fd9c87-fab8-447d-9384-9470c82f44f4
@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getName()); builder.append("\nWeight: ").append(this.getWeight()); builder.append("\nColor: ").append(this.getColor().toString()); builder.append("\nHardness: ").append...
d8b798b7-4a59-4e68-979b-252d1d567698
public SemipreciousStone() { this.price = 0; }
ab8b01b5-b5a7-40e8-9628-bdb11a298db4
public SemipreciousStone(int price) { this.price = price; }
e467206a-9551-4fe4-8e97-80b6558df30c
public void setPrice(int price) { this.price = price; }
ad499653-df37-43e2-a88e-72bb7c5a5a8f
public int getPrice() { return this.price; }
577b4642-5a75-401a-b7fe-ee7c1c1cdc6c
@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getName()); builder.append("\nWeight: ").append(this.getWeight()); builder.append("\nColor: ").append(this.getColor().toString()); builder.append("\nHardness: ").append...
00905de1-3e93-4a9e-895a-98fda952d44f
public Coral() { this.form = Form.UNDEFINED; this.size = 0; }
b61e22fb-a8db-490d-8f9d-0d84b56008d8
public Coral(Form form) { this.form = form; this.size = 0; }
be8ee58b-bf60-48c3-a2b3-6c1cf424653b
public Coral(Form form, int size) { this.form = form; this.size = size; }
bddc3a0f-1202-4068-bf58-58462e07ba8f
public void setForm(Form form) { this.form = form; }
4f2dc01b-ec12-4308-95b0-364099c7a9d4
public Form getForm() { return this.form; }
11873653-e99f-40ec-941e-19a4563c3312
public void setSize(int size) { this.size = size; }
5787716d-8724-44da-ba2e-8e9416624063
public int getSize() { return this.size; }
e0d74057-57e4-49e8-9a86-92c89a7a87eb
public Type getType() { return this.type; }
ad6a7b75-cb18-44b4-827b-6240a5e4581b
@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getName()); builder.append("\nWeight: ").append(this.getWeight()); builder.append("\nColor: ").append(this.getColor().toString()); builder.append("\nHardness: ").append...
b29b19cb-5b96-4c37-ac14-e2ef9cbebc82
public static void main(String[] args) { /*DOMParser.parse();*/ /*XMLSAXParser xmlsaxParser = new XMLSAXParser(); xmlsaxParser.parsingSAX();*/ StAXParser stAXParser = new StAXParser(); stAXParser.parseXML("src/resources/stone.xml"); }
29c38ef5-2e1b-466e-9781-47f9cf49ed25
public ArrayList<Stone> getStoneList() { return stoneList; }
2717e4a6-0966-4f4a-bb6e-3d4c688c6452
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { switch (qName) { case "stone": stone = new Stone(); stone.setId(Integer.parseInt(attributes.getValue("id"))); break; ...
91aaaaa5-31a7-4336-b457-02eaedb452bc
@Override public void endElement (String uri, String localName, String qName)throws SAXException { switch (qName) { case "stone": stoneList.add(stone); break; case "name": stone.setName(holder); ...
e5151c6b-385f-49ca-b44e-e7e449857b67
@Override public void characters ( char[] ch, int start, int length)throws SAXException { holder = String.valueOf(ch, start, length); }
2917061b-5c5f-4508-bf84-c0086aca62a4
public ArrayList<Stone> parsingSAX(){ try { SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); SAXParser parser = saxParserFactory.newSAXParser(); SAXHandler handler = new SAXHandler(); parser.parse(new File("src/resources/stone.xml"), handler); ...
8d5be32a-e148-417a-8e7c-89aca324d44c
public List<Stone> parseXML(String fileName) { try { XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); XMLStreamReader xmlReader = xmlInputFactory.createXMLStreamReader(new FileInputStream(fileName)); parseStAX(xmlReader); return stones; } c...
4aa80bf7-abe2-4cc5-b530-466e18d7c439
private void parseStAX(XMLStreamReader xmlReader) throws XMLStreamException { while (xmlReader.hasNext()) { int event = xmlReader.next(); switch (event) { case XMLStreamConstants.START_ELEMENT: String localName = xmlReader.getLocalName(); ...
b1f60565-56b4-4033-b4c9-b5a12be51de3
public static void parse() { try { File fXmlFile = new File("src/resources/stone.xml"); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(fXmlFile); ...
fce83ce9-68db-42d3-9db4-15a6144b94f4
public JPainterFrame(int width, int height) { super(); setSize(width, height); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); setResizable(true); setVisible(true); }
93ba126e-9f09-4247-88b7-1808d2755407
public JPainterDrawPad getDrawPad() { return drawPad; }
47a97f94-be24-48c2-96db-406a9baf04cd
public void setDrawPad(JPainterDrawPad drawPad) { this.drawPad = drawPad; Container content = getContentPane(); content.removeAll(); content.setLayout(new BorderLayout()); content.add(drawPad, BorderLayout.CENTER); drawPad.calculateShadow(); drawPad.repaint(); }
2d083e3a-c156-4b55-8bd8-8d514ccc5e39
public JPainterMenu() { super(); initFileMenu(); initEditMenu(); }
926b0614-cff4-4b36-9ab3-f8f4b5339c01
private void initFileMenu() { JMenu file = new JMenu("File"); JMenuItem newCanvas = new JMenuItem("New Canvas..."); newCanvas.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK)); // add action listener // file.add(newCanvas); JMenuItem openCanvas = new JMenuItem("Open Canv...
70a65c3c-b6de-4fd1-8e29-dcca74f08c37
private void initEditMenu() { JMenu edit = new JMenu("Edit"); add(edit); }
8ee344f9-c27e-4a98-be2e-9822f040f6a7
public static void main(String[] args) { JPainterFrame mainFrame = new JPainterFrame(1024, 768); mainFrame.setJMenuBar(new JPainterMenu()); mainFrame.setTitle("JPainter - alpha"); // mainFrame.setDrawPad(new JPainterDrawPad(800, 600)); }
f2ec20d2-65a9-4c7b-a3c0-bf5490b61286
public JPainterDrawPad(int width, int height) { setBounds(0, 0, width, height); this.width = width + insets.right; this.height = height + insets.bottom; brush = new JPainterBrush(); layers = new ArrayList<JPainterLayer>(); addLayer(new JPainterLayer(width, height)); activeLayer = layers.get(0); ...
e8ab2771-ef0e-4dba-9aed-9c70af686d3d
@Override public void penLevelEvent(PLevelEvent ev) { if(!ev.isMovement() || activeLayer == null) return; Graphics2D g2d = activeLayer.getGraphics(); float pressure = ev.pen.getLevelValue(PLevel.Type.PRESSURE); brush.setBrushSize(pressure * 10); brush.setFlow(pressure); lo...
a0bf97d7-d7a7-453e-aad1-938f81062f41
public int getWidth() { return width; }
4c0be44d-869b-4b7a-841b-e5c42ec85f6c
public void setWidth(int width) { this.width = width; }
51a684e6-008a-4f21-a476-90426c3f7035
public int getHeight() { return height; }
52505db4-c471-43b3-b0e3-befbf18a0f14
public void setHeight(int height) { this.height = height; }
d7adbbb3-0e4f-469b-baaf-b482c4d56c9c
@Override public Insets getInsets() { return insets; }
0e6140ca-bd93-4452-8236-f3b20154f631
public void addLayer(JPainterLayer layer) { layers.add(layer); }
8fd07ed7-ee9c-48d9-bd0a-6b092bfa6184
public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.drawImage(shadow, shadowSize, shadowSize, this); g2d.setColor(getBackground()); g2d.fill(shape); getUI().paint(g2d, this); g2d.setColor(Color.gray); g2d.draw(shape); // draw layers for(JPainterLayer layer : la...
bfe5cae2-0606-4956-a044-7010deb11736
public void calculateShadow() { int width = getWidth() - 1; int height = getHeight() - 1; Graphics g = getGraphics(); if(g == null) { return; } Graphics2D g2d = (Graphics2D) g; GraphicsUtils.applyQualitySettings(g2d); Insets insets = getInsets(); Rectangle bounds = getBounds(); bounds.x ...
74697e7b-e5c9-450b-8f9a-1296c4b5175d
private BufferedImage createCompatibleImage(int width, int height) { return createCompatibleImage(width, height, Transparency.TRANSLUCENT); }
18bf9d6a-9e7d-434f-9fe9-7c37e8507bf5
private BufferedImage createCompatibleImage(int width, int height, int transparency) { BufferedImage image = getGraphicsConfiguration().createCompatibleImage(width, height, transparency); image.coerceData(true); return image; }
9611a227-a462-49f5-bf1c-0c7347b8ae11
private BufferedImage generateShadow(BufferedImage image, int size, Color color, float alpha) { int imageWidth = image.getWidth() + (size * 2); int imageHeight = image.getHeight() + (size * 2); BufferedImage imageMask = createCompatibleImage(imageWidth, imageHeight); Graphics2D g2d = imageMask.createGraphics...
c604c66f-2563-4866-bd19-f73c7248a200
private BufferedImage generateBlur(BufferedImage image, int size, Color color, float alpha) { GaussianFilter filter = new GaussianFilter(size); int imageWidth = image.getWidth(); int imageHeight = image.getHeight(); BufferedImage imageBlur = createCompatibleImage(imageWidth, imageHeight); Graphics2D g2d...
11db399f-e27f-4ad9-a6a9-0da5ec4a7eb9
public JPainterLayer(int width, int height) { image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); graphics = image.createGraphics(); GraphicsUtils.applyQualitySettings(graphics); }
8ffe67da-93e4-48d8-a556-2024a4957914
public BufferedImage getImage() { return image; }
50ee0df8-7ff0-499c-8e8c-30d4c45427b4
public void setImage(BufferedImage image) { this.image = image; }
afc221e9-f0cb-4cd9-8db6-510d8801f50f
public Graphics2D getGraphics() { return graphics; }
3b8e8df0-f4b6-45c9-9011-0f63d982e525
public void setGraphics(Graphics2D graphics) { this.graphics = graphics; }
943d71b6-52b3-42d1-bbb5-690ae5b62cc7
public String getName() { return name; }
9849ee6d-3ae3-4b6b-b7c3-cc8ba6d723c1
public void setName(String name) { this.name = name; }
686b45cb-0d95-42e7-83ce-02e9ae407a3c
public float getOpacity() { return opacity; }
477285e3-418b-46dd-99e5-7627caa68ccd
public void setOpacity(float opacity) { this.opacity = opacity; }
a8eaa4cf-689d-4bbd-b43c-734c942bf15d
public void drawLayer(Graphics2D g) { Composite originalComposite = g.getComposite(); g.setComposite(GraphicsUtils.makeComposite(AlphaComposite.SRC_OVER, opacity)); g.drawImage(image, 0, 0, null); g.setComposite(originalComposite); }
475e2f58-e80e-47ef-800b-347a35c50b03
public float getBrushSize() { return brushSize; }
ebe78466-4a3e-4f49-8e72-aef0fde197a3
public void setBrushSize(float brushSize) { this.brushSize = brushSize; }
6e0521c7-80fd-4cbe-bc80-576964866a55
public float getFlow() { return flow; }
57d1d956-9732-4ee0-834d-7476d248d888
public void setFlow(float flow) { this.flow = flow; }
769b80cb-5e6e-457d-add9-824c69a204fa
public float getOpacity() { return opacity; }
aa3dcbbe-dd9c-43f6-aeed-dd6ef92d9c7a
public void setOpacity(float opacity) { this.opacity = opacity; }
6c66013e-1870-4fb6-a17b-4fd33c875261
public BasicStroke getStroke() { return stroke; }
e6f2a966-981f-48bb-9ae5-5e599534cfb7
public void setStroke(BasicStroke stroke) { this.stroke = stroke; }
5d1b80fb-72b0-4bd6-8e4b-08d49b488bc7
public boolean isPressureMode() { return pressureMode; }
39317c4c-0c1c-4cbe-8b5d-a0864bd83d3a
public void setPressureMode(boolean pressureMode) { this.pressureMode = pressureMode; }
c03a872c-19c8-4890-802d-6c93aded3dba
public static int clamp(int c) { if (c < 0) return 0; if (c > 255) return 255; return c; }
c23ab0f9-708c-4341-ad43-8a19319eaf14
public static int interpolate(int v1, int v2, float f) { return clamp((int)(v1+f*(v2-v1))); }
4eefff33-3eec-4ef1-8c06-6ab9ed1ab73a
public static int brightness(int rgb) { int r = (rgb >> 16) & 0xff; int g = (rgb >> 8) & 0xff; int b = rgb & 0xff; return (r+g+b)/3; }
47e5b7e7-5de3-43ad-bb20-a78366c67839
public static boolean nearColors(int rgb1, int rgb2, int tolerance) { int r1 = (rgb1 >> 16) & 0xff; int g1 = (rgb1 >> 8) & 0xff; int b1 = rgb1 & 0xff; int r2 = (rgb2 >> 16) & 0xff; int g2 = (rgb2 >> 8) & 0xff; int b2 = rgb2 & 0xff; return Math.abs(r1-r2) <= tolerance && Math.abs(g1-g2) <= tolerance && Mat...
45ff8347-3725-4372-abf2-9e0b32dd445c
public static int combinePixels(int rgb1, int rgb2, int op) { return combinePixels(rgb1, rgb2, op, 0xff); }
5601eff6-c7ca-48cb-9112-8f52e5be1308
public static int combinePixels(int rgb1, int rgb2, int op, int extraAlpha, int channelMask) { return (rgb2 & ~channelMask) | combinePixels(rgb1 & channelMask, rgb2, op, extraAlpha); }
daaf9dc7-ddf9-49c1-8559-66e14518460e
public static int combinePixels(int rgb1, int rgb2, int op, int extraAlpha) { if (op == REPLACE) return rgb1; int a1 = (rgb1 >> 24) & 0xff; int r1 = (rgb1 >> 16) & 0xff; int g1 = (rgb1 >> 8) & 0xff; int b1 = rgb1 & 0xff; int a2 = (rgb2 >> 24) & 0xff; int r2 = (rgb2 >> 16) & 0xff; int g2 = (rgb2 >> 8)...
939c668b-3acb-4196-87be-ffbf684203ec
public static void applyQualitySettings(Graphics2D g2d) { g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_...
a0978416-6f5c-4c8c-b045-0e63901cfac7
public static AlphaComposite makeComposite(int type, float alpha) { // int type = AlphaComposite.SRC_OVER; return AlphaComposite.getInstance(type, alpha); }
6e804037-c9aa-4fbc-b9b5-1226f484b334
public ConvolveFilter() { this(new float[9]); }
e34b703e-5ca3-4b7f-985d-a2d335f56c48
public ConvolveFilter(float[] matrix) { this(new Kernel(3, 3, matrix)); }
1b404ebd-d290-45c4-99ac-55dc0e8a3a2e
public ConvolveFilter(int rows, int cols, float[] matrix) { this(new Kernel(cols, rows, matrix)); }
9ee6f039-9272-40d3-ad32-1ed06d46f290
public ConvolveFilter(Kernel kernel) { this.kernel = kernel; }
29b08ead-30c2-4460-abea-b4f01d5b570b
public void setKernel(Kernel kernel) { this.kernel = kernel; }
6775ef26-4e3b-498e-91ec-86e4debf713b
public Kernel getKernel() { return kernel; }
6f7a17d7-660b-4239-8159-70d77a635bcf
public void setEdgeAction(int edgeAction) { this.edgeAction = edgeAction; }
bd3dae38-b41b-4f09-99fc-5dd9f4da7aae
public int getEdgeAction() { return edgeAction; }
457f9bab-4000-4e08-954f-3d3b057afaaa
public BufferedImage filter( BufferedImage src, BufferedImage dst ) { int width = src.getWidth(); int height = src.getHeight(); if ( dst == null ) dst = createCompatibleDestImage( src, null ); int[] inPixels = new int[width*height]; int[] outPixels = new int[width*h...
bf5eb2d5-be13-4152-a15a-977138e1befa
public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM) { if ( dstCM == null ) dstCM = src.getColorModel(); return new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight()), dstCM.isAlphaPremultiplied(), null); }
abfd9f79-e1af-4273-bcc6-2eb4535dcae0
public Rectangle2D getBounds2D( BufferedImage src ) { return new Rectangle(0, 0, src.getWidth(), src.getHeight()); }
672db299-80a7-4310-b0a1-6fd17dd1b2c3
public Point2D getPoint2D( Point2D srcPt, Point2D dstPt ) { if ( dstPt == null ) dstPt = new Point2D.Double(); dstPt.setLocation( srcPt.getX(), srcPt.getY() ); return dstPt; }
25bf2e6d-2875-4f80-bedf-f8e0e4d1dd2d
public RenderingHints getRenderingHints() { return null; }
9800fd0a-131c-4e5e-b8b4-c7709b1415de
public static void convolve(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, int edgeAction) { convolve(kernel, inPixels, outPixels, width, height, true, edgeAction); }
4cb899ca-468f-4540-94b8-b01f0f3d051c
public static void convolve(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction) { if (kernel.getHeight() == 1) convolveH(kernel, inPixels, outPixels, width, height, alpha, edgeAction); else if (kernel.getWidth() == 1) convolveV(kernel, inPixels, outPixels, wid...
3e0ba3a8-6899-483d-a86a-a1c566f93484
public static void convolveHV(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction) { int index = 0; float[] matrix = kernel.getKernelData( null ); int rows = kernel.getHeight(); int cols = kernel.getWidth(); int rows2 = rows/2; int cols2 = cols/2; for (int...