API Review RT:17407 Canvas Node
Kevin Rushforth
kevin.rushforth at oracle.com
Thu Apr 19 06:05:41 PDT 2012
It seems like there is quite a bit of interest in a more generic
immediate-mode rendering interface.
One problem with making GraphicsContext an interface is that you are
then precluded from evolving it in a compatible manner. You are stuck
introducing GraphicsContext2, GraphicsContext3, etc., and doing
instanceof checks. Also, I would guess that some of the methods would
not want to be part of the interface for non-Canvas implementations. I
hope Jim can chime in here and respond.
Going out with a publicly-exposed javafx.scene.canvas.GraphicsContext
class wouldn't preclude later introducing a generic interface that
GraphicsContext could then implement (with all or a subset of the
methods), which would then allow other implementations.
> I even dare to propose to rewrite the charting package based on this
interface.
I question the value of this, but in any case it would be an
implementation detail.
-- Kevin
Dr. Michael Paus wrote:
> Yes, this interface should be a general purpose 2D drawing interface
> and should contain
> nothing specific to Canvas and should also not reside in the canvas
> package. Canvas only
> provides one possible implementation of it with possibly some
> additional canvas specific features.
>
> I even dare to propose to rewrite the charting package based on this
> interface. This would increase
> the longterm usefulness of the charting package and at the same time
> would be a very good test-case
> for the completeness and usefulness of the canvas implementation itself.
>
> LG, Michael
>
> Am 19.04.2012 12:08, schrieb Daniel Zwolenski:
>> I like what Michael Paus is suggesting. Unless there is a need to
>> couple this with Canvas it would be good to keep it seperate.
>>
>>
>> On 19/04/2012, at 2:57 PM, "Dr. Michael Paus"<mp at jugs.org> wrote:
>>
>>> A Canvas node is very important but we should not limit the
>>> GraphicsContext to be only usable for it.
>>> Instead we should make GraphicsContext an interface and Canvas
>>> should then provide a CanvasGraphicsContext
>>> which implements this interface. The advantage would be that code
>>> can be written against that interface and
>>> if someone else writes a renderer for other output formats you can
>>> then immediately render into that format
>>> too like it is currently done for SVG, PDF and other formats by
>>> tools like Batik, iText, etc.
>>>
>>> LG, Michael
>>>
>>> Am 19.04.2012 00:36, schrieb joe andresen:
>>>> Hello Everyone,
>>>>
>>>> We propose to add a Canvas node and GraphicsContext to a new
>>>> javafx.scene.canvas package for JavaFX 2.2. The javafx.scene.canvas
>>>> package provides a pair of classes for an immediate mode style API for
>>>> rendering. Canvas Node works seemlessly with effects as well as
>>>> Animation timers, and will be tightly bound to the new ImageOps API.
>>>>
>>>> This new API will allow HTML5 Canvas users to easily port their
>>>> existing applications that make heavy use of the HTML5 canvas directly
>>>> to JavaFX without the need to morph their application to fit the
>>>> scenegraph model.
>>>>
>>>> You can Download and unzip the (preliminary) relevant docs here:
>>>> JIRA: http://javafx-jira.kenai.com/browse/RT-17407
>>>>
>>>> Note that the docs are a work in progress but should be enough for API
>>>> Review. (Also, Jira will be down Thursday 4/19 at 1400 PDT for a
>>>> while).
>>>>
>>>> A list of the the methods for Canvas and GraphicsContext are listed
>>>> below.
>>>>
>>>> Canvas:
>>>>
>>>> GraphicsContext getGraphicsContext2D()
>>>> double getHeight()
>>>> double getWidth()
>>>> DoubleProperty heightProperty()
>>>> void setHeight(double value)
>>>> void setWidth(double value)
>>>> DoubleProperty widthProperty()
>>>>
>>>> GraphicsContext:
>>>> void appendSVGPath(java.lang.String svgpath)
>>>> void applyEffect(Effect e)
>>>> void arc(double centerX, double centerY, double radiusX, double
>>>> radiusY, double startAngle, double length)
>>>> void arcTo(double x1, double y1, double x2, double y2, double
>>>> radius)
>>>> void beginPath()
>>>> void bezierCurveTo(double xc1, double yc1, double xc2, double yc2,
>>>> double x1, double y1)
>>>> void clearRect(double x, double y, double w, double h)
>>>> void clip()
>>>> void closePath()
>>>> void drawArc(double x, double y, double w, double h, double
>>>> startAngle, double arcExtent, ArcType closure)
>>>> void drawImage(Image img, double x, double y)
>>>> void drawImage(Image img, double x, double y, double w, double h)
>>>> void drawImage(Image img, double sx, double sy, double sw, double
>>>> sh, double dx, double dy, double dw, double dh)
>>>> void drawLine(double x1, double y1, double x2, double y2)
>>>> void drawOval(double x, double y, double w, double h)
>>>> void drawPolygon(double[] xPoints, double[] yPoints, int nPoints)
>>>> void drawPolyline(double[] xPoints, double[] yPoints, int nPoints)
>>>> void drawRoundRect(double x, double y, double w, double h, double
>>>> arcWidth, double arcHeight)
>>>> void fill()
>>>> void fillArc(double x, double y, double w, double h, double
>>>> startAngle, double arcExtent, ArcType closure)
>>>> void fillOval(double x, double y, double w, double h)
>>>> void fillPolygon(double[] xPoints, double[] yPoints, int nPoints)
>>>> void fillRect(double x, double y, double w, double h)
>>>> void fillRoundRect(double x, double y, double w, double h, double
>>>> arcWidth, double arcHeight)
>>>> void fillText(java.lang.String text, double x, double y)
>>>> void fillText(java.lang.String text, double x, double y, double
>>>> maxWidth)
>>>> Canvas getCanvas()
>>>> boolean isPointInPath(double x, double y)
>>>> void lineTo(double x1, double y1)
>>>> double measureText(java.lang.String text)
>>>> void moveTo(double x0, double y0)
>>>> void putImageData(GraphicsContext.ImageData imagedata, double dx,
>>>> double dy)
>>>> void putImageData(GraphicsContext.ImageData imagedata, double dx,
>>>> double dy, double dirtyX, double dirtyY, double dirtyWidth, double
>>>> dirtyHeight)
>>>> void quadraticCurveTo(double xc, double yc, double x1, double y1)
>>>> void rect(double x, double y, double w, double h)
>>>> void restore()
>>>> void rotate(double degrees)
>>>> void save()
>>>> void scale(double x, double y)
>>>> void setEffect(Effect e)
>>>> void setFill(Paint p)
>>>> void setFont(Font f)
>>>> void setGlobalAlpha(double alpha)
>>>> void setGlobalCompositeOperation(GraphicsContext.CompositeOperation
>>>> op)
>>>> void setLineCap(StrokeLineCap cap)
>>>> void setLineJoin(StrokeLineJoin join)
>>>> void setLineWidth(double lw)
>>>> void setMiterLimit(double ml)
>>>> void setStroke(Paint p)
>>>> void setTextAlign(TextAlignment align)
>>>> void setTextBaseline(VPos baseline)
>>>> void setTransform(double mxx, double myx, double mxy, double myy,
>>>> double mxt, double myt)
>>>> void stroke()
>>>> void strokeRect(double x, double y, double w, double h)
>>>> void strokeText(java.lang.String text, double x, double y)
>>>> void strokeText(java.lang.String text, double x, double y, double
>>>> maxWidth)
>>>> void transform(double mxx, double myx, double mxy, double myy,
>>>> double mxt, double myt)
>>>> void translate(double x, double y)
>>>
>>> --
>>> --------------------------------------------------------------------------------------
>>>
>>> Dr. Michael Paus, Chairman of the Java User Group Stuttgart e.V.
>>> (JUGS).
>>> For more information visit www.jugs.de.
>
>
More information about the openjfx-dev
mailing list