shapes

Scaling/Translating a Shape to a given Rectangle using AffineTransform

旧城冷巷雨未停 提交于 2019-11-27 09:36:09
I'm trying to scale/translate a java.awt. Shape with AffineTransform in order to draw it in a defined bounding Rectangle. Moreover, I want to paint it in a drawing Area having a ' zoom ' parameter. I tried various concatenations of AffineTransform but I couldn't find the correct sequence. For example, the following solution was wrong: double zoom=(...);/* current zoom */ Rectangle2D viewRect=(...)/** the rectangle where we want to paint the shape */ Shape shape=(...)/* the original shape that should fit in the rectangle viewRect */ Rectangle2D bounds=shape.getBounds2D(); double ratioW=

Border in shape xml

时间秒杀一切 提交于 2019-11-27 09:16:27
问题 I am trying to make a drawable to use for a button. I would like it to have this coloring, with a 2px border around it. Everything works just fine except I cannot get the border to show up... <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:startColor="@color/bar_clicked_dark" android:endColor="@color/bar_clicked_light" android:angle="90"/> <corners android:bottomLeftRadius="0dp" android

Multipe shapes inside shapes.xml in android

老子叫甜甜 提交于 2019-11-27 06:54:46
问题 I have been searching for possibilities to define different shapes inside a single shapes.xml and refer to each one on some specific events. At last I've found a solution to my question. And the answer is using level-list. <?xml version="1.0" encoding="utf-8"?> <level-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:maxLevel="0"> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#aaa"

How to save a Google maps overlay shape in the database?

点点圈 提交于 2019-11-27 06:46:09
I want to save a Google maps overlay shape in the database. This is my code. It works perfectly but I just need to save all_shapes array in the database. <html> <head> <style type="text/css"> #map, html, body { padding: 0; margin: 0; height: 100%; } </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&libraries=drawing,geometry"></script> <script> var coordinates = []; var all_shapes = []; var selectedShape; </script> <script> function draw_shape() { for(var i = 0; i < all_shapes.length; i++) { all_shapes[i].setMap(null); } for(var i = 0; i < all_shapes

Java make a directed line and make it move

做~自己de王妃 提交于 2019-11-27 05:13:37
I want to make a directed line and make it move. I am able to make a directed line and move the line but the arrow get displaced while i move the line This is my paint method Line2D.Double line = new Line2D.Double(startX, startY, endX, endY); g2d.draw(line); tx.setToIdentity(); double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1); tx.translate(line.x2, line.y2); tx.rotate((angle - Math.PI / 2d)); Graphics2D gClone = (Graphics2D) g2d.create(); gClone.setTransform(tx); Polygon arrowHead = new Polygon(); arrowHead.addPoint(0, 15); arrowHead.addPoint(-15, -15); arrowHead.addPoint(15,

Java check if two rectangles overlap at any point

不羁的心 提交于 2019-11-27 01:08:20
I have multiple rectangles and one special rectangle: the selection rect. I want to check for each rectangle if the rectangle contains at least one point which is inside the selection rectangle. Here is an image for clarity: CodeCamper This will find if the rectangle is overlapping another rectangle: public boolean overlaps (Rectangle r) { return x < r.x + r.width && x + width > r.x && y < r.y + r.height && y + height > r.y; } We can determine a rectangle with only one of its diagonal. Let's say left rectangle's diagonal is (x1, y1) to (x2, y2) And right rectangle's diagonal is (x3, y3) to (x4

Google Maps Polygons self intersecting detection

坚强是说给别人听的谎言 提交于 2019-11-26 21:29:14
问题 I'm trying to implement a polygon self intersection algorithm from Google Maps API V3 polygons. The goal is just to detect if yes or no, a simple polygon drawn by the user is self crossing. I have found this very interesting link, but it assumes that coordinates of the polygon's vertices are given on geoJSON format. However, this isn't my case ; I'm only able to retrieve polygons coordinates using polygon.getPath() into a polygoncomplete event. This is how i retrieve the coordinates : google

How to compare two shapes?

淺唱寂寞╮ 提交于 2019-11-26 20:58:19
Is there a way to compare two geometric shapes (or any two more generic data structures), without using the brute force when a tolerance is involved? The brute force (that is comparing each value of each object against each value of the other object) works but it's slow, and I can't use it. I tried sorting the data and comparing two sorted collections. It's fast, but it only works with zero tolerance. As soon as I add the tolerance I get lost. The problem is that two values can be identical when I compare and different when I sort. Here are some details of my problem. In my Excel VBA add-in I

Two Rectangles intersection

僤鯓⒐⒋嵵緔 提交于 2019-11-26 20:19:18
I have two rectangles characterized by 4 values each : Left position X , top position Y , width W and height H : X1, Y1, H1, W1 X2, Y2, H2, W2 Rectangles are not rotated, like so: +--------------------> X axis | | (X,Y) (X+W, Y) | +--------------+ | | | | | | | | | | +--------------+ v (X, Y+H) (X+W,Y+H) Y axis What is the best solution to determine whether the intersection of the two rectangles is empty or not? Tao Peng if (X1+W1<X2 or X2+W2<X1 or Y1+H1<Y2 or Y2+H2<Y1): Intersection = Empty else: Intersection = Not Empty If you have four coordinates – ((X,Y),(A,B)) and ((X1,Y1),(A1,B1)) –

How do I draw lines using XNA?

做~自己de王妃 提交于 2019-11-26 19:48:23
问题 I've read a bunch of tutorials involving XNA (and it's various versions) and I still am a little confused on drawing primitives. Everything seems to be really convoluted. Can someone show me, using code, the simplest XNA implementation of drawing one or two lines on to the screen? Perhaps with a brief explanation (including the boilerplate)? I'm not a games programmer and I have little XNA experience. My ultimate goal is to draw some lines onto the screen which I will eventually transform