paint

JTable returning null for Graphics?

混江龙づ霸主 提交于 2019-11-30 10:02:05
问题 I'm trying to draw lines over my JTable using a Painter object that I've made, but for some reason table.getGraphics() returns null. Painter class: import java.awt.BasicStroke; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JTable; public class Painter extends JTable { public Painter(){ } public void paintSudokuLines(Graphics g){ paintComponent(g); } public void paintComponent(Graphics g){ super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; g2.setStroke(new

How can I tell if a Delphi control is currently visible?

谁都会走 提交于 2019-11-30 07:08:53
I need a way to for a custom control (descended from TCustomControl) to tell if it is currently visible. I'm not talking about the .Visible property; I mean whether or not it's actually being displayed on-screen at the moment. Does anyone know how to do this? A few years back I had the same kind of problem for a Form: I was looking for a way to determine if a Form is actually visible (even only partially) to the user. In particular when it was supposed to be visible and Showing was True but the window was actually entirely behind another one. Here's the code, it could be adapted for a

How to prevent Android's drawBitmap from only drawing black images?

老子叫甜甜 提交于 2019-11-30 06:16:07
问题 As per the original question, The end result is a rounded-rect png in an ImageView with a natural looking drop shadow. I have the shadow working, but when it draws, it makes the entire image black. How can I prevent the original image (definitely not black) from being black when adding the shadow? BlurMaskFilter blurFilter = new BlurMaskFilter(2, BlurMaskFilter.Blur.OUTER); Paint shadowPaint = new Paint(); shadowPaint.setMaskFilter(blurFilter); int[] offsetXY = new int[2]; Bitmap

How to set paint.setColor(R.color.white)

♀尐吖头ヾ 提交于 2019-11-30 06:11:25
I have a custom View that uses Paint and Canvas to draw objects. My question is how to set: int color = R.color.white; paint.setColor(color); from my /res/valuse/color.xml which includes resources like <?xml version="1.0" encoding="utf-8"?> <resources> <color name="white">#FFFFFF</color> <color name="black">#000000</color> ... </resources> Vitali Olshevski int color = ContextCompat.getColor(context, R.color.white); paint.setColor(color); The setColor() method takes a color number as int value, but not a resource id which is an int as well. Hani Hussein Try using color.white : paint.setColor

Strange crash drawing on canvas on Android 4.0.3. A/libc: Fatal signal 11 (SIGSEGV)

ぐ巨炮叔叔 提交于 2019-11-30 05:27:23
问题 I'm using a low cost tablet with Android 4.0.3. Here the log: 06-11 23:36:04.653: D/SynopticElement(1583): Size changed to 200x200 06-11 23:36:04.693: D/dalvikvm(1583): GC_FOR_ALLOC freed 62K, 12% free 7275K/8199K, paused 33ms 06-11 23:36:04.713: D/SynopticElement(1583): Size changed to 190x190 06-11 23:36:04.733: D/dalvikvm(1583): GC_FOR_ALLOC freed 9K, 12% free 7583K/8583K, paused 22ms 06-11 23:36:04.743: A/libc(1583): Fatal signal 11 (SIGSEGV) at 0xc52c9d4c (code=1) Debugging my code:

How to get height of text with fixed width and get text length which fits in a frame?

僤鯓⒐⒋嵵緔 提交于 2019-11-30 05:22:45
well, I've managed to fit all my questions in the title. I need to break a long text in to columns/frames and layout them in to view. I've been digging for solutions for a couple of days now, but I can't find any examples or clear documentation on how to complete any of my tasks. I've seen a some mentions of StaticLayout, but I don't know how to use it properly. As for text height I've tried TextPaint's getTextBounds method, but it doesn't have width limit and it looks like it measures only single line (well, maybe I was doing something wrong). Maybe someone has an example of StaticLayout or

Android FingerPaint Undo/Redo implementation

廉价感情. 提交于 2019-11-30 04:01:40
I'm working on a test project which is something similar to FingerPaint example in Android SDK Demos. I was trying to implement undo/redo functionality in my project,but the things that I tried didn't work as I expect. I find some questions similar to this over internet and here,but they didn't help me, that's why I'm asking a new question. Here is some idea what I'm doing actually : public class MyView extends View { //private static final float MINP = 0.25f; //private static final float MAXP = 0.75f; private Path mPath; private Paint mBitmapPaint; public MyView(Context c) { super(c); mPath =

Efficient Line Smoothing and/or Simplification

廉价感情. 提交于 2019-11-30 02:31:25
I am creating a painting application in Actionscript (although my question is not Actionscript related). The basic idea is to start painting when the mouse is pressed and tracking the mouse movements. What I want to achieve is: reduce mouse "noise" and create more smoother looking lines. Right now, ( 1 ) is problematic because I get thousands of mouse movements within a few seconds. Due to ( 1 ) the line can look jaggy. What current idea: when the user finishes drawing the line, I store all movements in an array and reduce them (median threshold) and then use a spline algorithm to recreate a

How to draw smooth / rounded path?

为君一笑 提交于 2019-11-29 23:44:01
I am creating Paths and adding multi lines in each path by using path.moveTo(x, y) and path.lineTo(x, y) . Then canvas.drawPath(path, paint) is drawing all paths. But there are 1-2 pixel space between lines in some paths. How can I remove these spaces? My code is something like that: paint = new Paint(); paint.setColor(Color.RED); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setDither(false); paint.setStrokeWidth(3); paint.setAntiAlias(true); for (int i = 0; i < length; i++) { Path path = new Path(); path.moveTo(a, b); path.lineTo(c, d); path.moveTo(c, d); path.lineTo(e, f); canvas

How to draw a curved line between 2 points on canvas?

浪子不回头ぞ 提交于 2019-11-29 21:35:08
问题 I have tried a lot of different approaches from examples around the web, but I can't seem to get this to work. I am trying to make a method that draws a curved line between 2 points on a canvas. The curve should be defined by a radius parameter. Below is my current code. public OverlayBuilder drawCurvedArrow(int startX, int startY, int endX, int endY, int curveRadius, int padding, int color) { PointF mPoint1 = new PointF(startX, startY); PointF mPoint2 = new PointF(endX, endY); Paint paint =