How to draw a circle with animation in android with circle size based on a value

You have to draw the circle view, and after that you should create an animation to it. Creating the circle view: public class Circle extends View { private static final int START_ANGLE_POINT = 90; private final Paint paint; private final RectF rect; private float angle; public Circle(Context context, AttributeSet attrs) { super(context, attrs); final int … Read more

Android: how to draw a border to a LinearLayout

Do you really need to do that programmatically? Just considering the title: You could use a ShapeDrawable as android:background… For example, let’s define res/drawable/my_custom_background.xml as: <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”rectangle”> <corners android:radius=”2dp” android:topRightRadius=”0dp” android:bottomRightRadius=”0dp” android:bottomLeftRadius=”0dp” /> <stroke android:width=”1dp” android:color=”@android:color/white” /> </shape> and define android:background=”@drawable/my_custom_background”. I’ve not tested but it should work. Update: I think that’s better to … Read more

Write text on an image in C#

To draw multiple strings, call graphics.DrawString multiple times. You can specify the location of the drawn string. This example we will draw two strings “Hello”, “Word” (“Hello” in blue color upfront “Word” in red color): string firstText = “Hello”; string secondText = “World”; PointF firstLocation = new PointF(10f, 10f); PointF secondLocation = new PointF(10f, 50f); … Read more

draw polar graph in java

You might like to look at Lissajous curves; an example of a = 5, b = 4 (5:4) is shown below. Addendum: Once you see how to plot points in xy coordinates, then you should look at converting between polar and Cartesian coordinates. public class LissajousPanel extends JPanel { private static final int SIZE = … Read more

JFreechart draw arc on chart

The critical thing about Arc2D is the bounding rectangle. To make the half-arc H units high, the bounds must be 2 * H units high. AFAIK, PolarPlot does not support annotations. import java.awt.BasicStroke; import java.awt.Color; import java.awt.geom.Arc2D; import java.util.Random; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFrame; import org.jfree.chart.JFreeChart; import org.jfree.chart.annotations.XYLineAnnotation; import org.jfree.chart.annotations.XYShapeAnnotation; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.XYDataset; … Read more

Can I draw rectangle in XML?

Yes you can and here is one I made earlier: <?xml version=”1.0″ encoding=”UTF-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/listview_background_shape”> <stroke android:width=”2dp” android:color=”#ff207d94″ /> <padding android:left=”2dp” android:top=”2dp” android:right=”2dp” android:bottom=”2dp” /> <corners android:radius=”5dp” /> <solid android:color=”#ffffffff” /> </shape> You can create a new XML file inside the drawable folder, and add the above code, then save it as rectangle.xml. To … Read more

How to draw in JPanel? (Swing/graphics Java)

Note the extra comments. import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; class JavaPaintUI extends JFrame { private int tool = 1; int currentX, currentY, oldX, oldY; public JavaPaintUI() { initComponents(); } private void initComponents() { // we want a custom Panel2, not a generic JPanel! jPanel2 = new Panel2(); jPanel2.setBackground(new java.awt.Color(255, 255, 255)); jPanel2.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); … Read more