WebView behavior

Hi, all.
I'm trying to create table with the use of WebView like this.
WebView view = new WebView();
view.getEngine().loadContent("<html><head></head><body><table>...</table></body></html>");1. How to fit the WebView size to the table size ?
This table size is static (JavaScript does not change size).
2. Sometimes WebView displays nothing, but table exists.
If I drag or select table, WebView displays it, like a following image.
[ http://postimage.org/image/exluawsml/| http://postimage.org/image/exluawsml/]
# Table exists in white - not selected space too.
I intended to make simple code to upload here,
but ended up not reproducing it.
Does anyone face same phenomenon or know how to solve this problem ?
JavaFX 2.0
JDK 1.6.0_30
Thanks in advance.

910538 wrote:
1. How to fit the WebView size to the table size ?
This table size is static (JavaScript does not change size).There is no simple API to enable that. Try obtaining the computed table size via JavaScript or DOM (see WebEngine.executeScript and WebEngine.getDocument) once the document is loaded and setting the WebView size accordingly.
2. Sometimes WebView displays nothing, but table exists.
If I drag or select table, WebView displays it, like a following image.
[ http://postimage.org/image/exluawsml/| http://postimage.org/image/exluawsml/]
This looks like a bug. Try the latest GA (JavaFX 2.0.3) or developer preview version. If the problem still exists, file an issue with Jira.
I intended to make simple code to upload here,
but ended up not reproducing it.
Does anyone face same phenomenon or know how to solve this problem ?
JavaFX 2.0
JDK 1.6.0_30
Thanks in advance.

Similar Messages

  • How to disable webview cache for Windows Phone 8.1 Runtime universal app?

    Is it possible to disable cache for the Webview control for a Windows Phone 8.1 runtime universal app? My App seems to be remembering the information it received the first time. My app logs me into a service and when I go back to rerun app in the emulator
    (without completing shutting down the emulator) it logs me in automatically rather than giving me the prompt. This behavior is in the NavigationCompleted handler if that helps explain a bit more on where I am hitting this issue.
    If I were to shut off the emulator completely and then restart it then I am prompted for the login name and password again. I have gotten over this cache issue, when I was using the HttpClient in other part of my app, by sending the no-cache in the header
    as:
    client.DefaultRequestHeaders.Add("Cache-Control", "no-cache");
    Can I do something similar for the webview control?
    thanks
    mujno

    Hi mujno,
    As I know currently there is no programmatically way to clean cache for WebView, see Matt's blog:How to clear the WebView cache
    However if you are developing an enterprise app, you should be able to invoke some scripts to clean for you, see this for more information:Brokered
    Windows Runtime Components for side-loaded Windows Store apps
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Is html5 dnd really supported in WebView?

    Hi,
    While testing dnd support in WebView, I faced a strange behavior regarding the transferable data retrieved.
    The data is always "*undefined*" in WebView, and is correct under other browsers...
    Any idea? Workaround?
    Thanks.
    Simply load the following HTML page into WebEngine.
    Try to drag the top rectangle into the second one.
    Note: Due to syntax highlighting in this forum the complete HTML code does not appear! The following attributes are missing on first and second div. Sorry.
    ondragstart="startDrag(event)
    ondrop="drop(event)" ondragover="canDrop(event)
    <!DOCTYPE HTML>
    <html>
         <head>
         <style type="text/css">
              #drop1 {width:350px;height:70px;padding:10px;border:1px solid #aaaaaa;}
              #startDrag1 {width:350px;height:70px;padding:10px;border:1px solid #000000;}
         </style>
         <script>
         function canDrop(ev)
              ev.preventDefault();
         function startDrag(ev)
              ev.dataTransfer.setData("Text",ev.target.id);
         function drop(ev)
              ev.preventDefault();
              var data=ev.dataTransfer.getData("Text");
              var result=document.getElementById("result");
              // Display result in Div and alert
              result.innerHTML=data;
              alert(data);
         </script>
    </head>
    <body>
         <p>Drag the top rectangle into the second:</p>
         <div style="color:#FFFF00;border: 2px dotted  black;" id="startDrag1" ondragstart="startDrag(event)"></div>
         <br/>
         <div style="color:#00FFFF;border: 3px dashed black;" id="drop1" ondrop="drop(event)" ondragover="canDrop(event)">
           <output id="result"></output>
         </div>
         <br>
    </body>
    </html>

    I played around with this a little bit using your example and the behaviour of JavaFX seemed buggy to me.
    If I set the data type to Text, I could reproduce the undefined message in the drop box. I thought maybe it just wasn't looking up the event target id ok, so I changed to set the text to a static string, and the behaviour was still the same (still printed undefined in the drop box). I thought I'd try a well defined data type of text/plain rather than Text, and then I didn't get undefined in the drop box, but I didn't get the text displayed there either, just nothing at all. Additionally the drag initiation seemed buggy and only worked for me sometime all of the time I was trying it. For instance, a lot of the time rather than the drag cursor, I'd end up with a selection being done or a text insert caret which prevented the use of of the drag and drop function as it seemed the drag and drop wasn't initialized. Only on the fifth or sixth attempt would a drag seem to be initiated. So I wouldn't really advise making use of html5 dnd in your app until you file some bugs on this at http://javafx-jira.kenai.com and they are fixed.
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.web.WebView;
    import javafx.stage.Stage;
    public class WebViewDragAndDrop extends Application {
      final static String html =
    "<!DOCTYPE HTML>\n"+
    "<html>\n"+
    "\t<head>\n"+
    "\t<style type=\"text/css\">\n"+
    "\t\t#drop1 {width:350px;height:70px;padding:10px;border:1px solid #aaaaaa;}\n"+
    "\t\t#startDrag1 {width:350px;height:70px;padding:10px;border:1px solid #000000;}\n"+
    "\t</style>\n"+
    "\t<script>\n"+
    "\tfunction canDrop(ev)\n"+
    "\t{\n"+
    "\t\tev.preventDefault();\n"+
    "\t}\n"+
    "\t\n"+
    "\tfunction startDrag(ev)\n"+
    "\t{\n"+
    "\t\tev.dataTransfer.setData('text/plain','xyzzy');\n"+
    "\t}\n"+
    "\t\n"+
    "\tfunction drop(ev)\n"+
    "\t{\n"+
    "\t\tev.preventDefault();\n"+
    "\t\tvar data=ev.dataTransfer.getData('text/plain');\n"+
    "\t\tvar result=document.getElementById(\"result\");\n"+
    "\t\t\n"+
    "\t\t// Display result in Div and alert\n"+
    "\t\tresult.innerHTML=data;\n"+
    "\t}\n"+
    "\t</script>\n"+
    "</head>\n"+
    "<body>\n"+
    " \n"+
    "\t<p>Drag the top rectangle into the second:</p>\n"+
    "\t\n"+
    "\t<div ondragstart='startDrag(event)' style=\"color:#FFFF00;border: 2px dotted  black;\" id=\"startDrag1\"></div>\n"+
    "\t<br/>\n"+
    "\t<div ondrop='drop(event)' ondragover='canDrop(event)' style=\"color:#00FFFF;border: 3px dashed black;\" id=\"drop1\">\n"+
    "\t  <output id=\"result\"></output>\n"+
    "\t</div>\n"+
    "\t\n"+
    "\t<br>\n"+
    " \n"+
    " \n"+
    "</body>\n"+
    "</html>"; 
      public static void main(String[] args) { launch(args); }
      @Override public void start(Stage stage) {
        WebView webview = new WebView();
        webview.getEngine().loadContent(html);
        stage.setScene(new Scene(webview, 750, 450));
        stage.show();
    }

  • WebView crashes on Windows 8.1

    Hi,
    I am using WebView to display web content in my app. I provide back/forward buttons to allow backward/forward navigation in the WebView. On press of back button I simply call
    WebView.GoBack() which is obviously protected by CanGoBack. Similarly I call
    WebView.GoForward() on press of Forward button.
    Now when I browser few websites and navigate Back and Forward few times the application crashes. I am not getting anything in the UnhandleException callback neither do I catch any exception on marking everything in Debug -> Exceptions.
    I tested this behavior with a sample app too.
    Here's code for that. To reproduce, browse http://www.google.com first then browse http://www.bbc.com and alternate between these with Back and Forward buttons little fast. Application will crash in no time.
    Is this a known bug with WebView or am I doing something wrong?
    Regards,
    Vinay

    Hello Matt,
    Since the Webview is a control available in Visual Studio I assumed that the fix would be available as an update for all Visual Studio versions as soon as possible. I don't see the association with Windows 10 as being the key milestone for 'probably' providing
    a fix for this issue unless it's a browser or OS version specific problem, but even then any web related control design should still internally provide script error trapping/rethrow as  an exception type that can be handled by the
    host app for any current OS or browser version. For those of us currently using the Webview control in our published apps, and there are many, that news doesn't provide much comfort and certainly won't help any app's reviews. What's particularly frustrating
    is that in an earlier post you stated that this problem might be a regression (fixed earlier and then broken again). If that's the case then why wait until 'probably' Windows 10? I'm very disappointed that the Microsoft team is obviously not
    taking this issue seriously. Most of us don't like to leave our apps sitting in the store with a known bug, especially one that we cannot personally fix. If I can't get a more definitive timeline I'll be forced to remove any published app from the store currently
    using this control.
     In any case, thank you very much for your time, responses, and assistance.

  • Mobile Safari / Webview - closing quicktime media does not return to page

    Hello. I have noticed that recently, with the 4.3.1 update, when you click 'Done' in a quicktime player window invoked from a Mobile Safari or webView page, the player controls disappear, but the quicktime logo stays on the screen.
    In previous versions of IOS, when you click Done, it returns you to the calling page.
    Simple test: create a webpage with a link to a MP3 file. Load it in Safari, click it to invoke the Quicktime player. Pre-4.3.1, when you click Done, the player exists and returns you to the webpage. On 4.3.1, when you click Done, the player remains on the screen, and you have to use Mobile Safari's controls to navigate back to the page.
    Anyone know how to revert to pre-4.3.1 behavior?

    I haven't submitted a report nor feedback because, quite frankly, I seldomly venture into Apple's sites and I have not submitted a bug report to Apple before, nor would I know how to do so. I also assumed, perhaps incorrectly, that Apple has staff perusing these forums and taking notes and passing them to QA and their developers.
    But I agree, submitting a bug report/feedback is a great idea. I'll figure it out and do so tomorrow when I have more time.
    By the way, why did '*****,' appear in my post? I didn't use any obscene words.

  • Unexpected behavior with UIWebView and Apple website

    I am experiencing a very weird behavior when I try to load the new Apple website (www.apple.com) within a UIWebView. It first loads ok but when it finishes loading the WebView switches to a blank page.
    I don't experience this kind of problem with other websites that I have tested. Therefore I don't believe that this is an issue of my application.
    Could someone please do me a favor and confirm this behavior?
    Thanks a lot,
    Florian

    Actually, Apple has always supported using custom folders in iMap for Deleted Messages, Drafts, Sent, & Junk. But I agree that with the release of 10.7.2 and iCloud with their new Archive feature, they haven't made it easy!
    I run my Mac in Swedish, so forgive me if I don't remember or get the exact wording of each option 100% correct, but I'm sure you'll figure it:
    In Mail Settings under your iCloud account, and in the middle tab (Mail Box Functions?), under the trash option at the bottom, make sure that:
    Move deleted mail to the trash can is Checked!
    Save deleted mail on on the server is Checked!
    Delete trashed (?) mail permanently is set to NEVER!
    Then go back to the main mail window and display the folders for your iCloud account on the LH side
    Select your achive folder.
    Go to the Mail Box menu in the menubar, Select "Use this mailbox for..." and then Select trash.
    You will not notice that your archive folder now appears under the trash can in Apple Lion Mail (and the deleted items folder that is no longer the trash will appear under the folders).
    This works a treat, and in fact I use this for Gmail as well. If you're interested, I have so much mail in all mail, but I want to have everything in Apple Mail. I also get to have a private backup on my Mac (and Time Machine).
    So, in Gmail, I have an "Apple Trash" folder which I link to deleted items as above, and which every six months or so I relabel (in the gmail app) to another folder. That way I don't have 50,000 mails in my trash. I don't activate All Mail in Gmail's IMAP because everything I have is always in at least one other folder / lable which syncs to my mac!

  • Webview on menue buttons broken in r25

    Hello,
    any information why the behavior of custom menu items configured as webview have totaly changed ??
    up tp sprint 24, external http:// or https:// links pointing to an customer selfeservice system, where kept and displaied within the app, now they open a
    safari browser instance, even without the notification of exiting the app.
    thnx for any information, how to address this problem
    kind regards
    Michael

    Hello,
    thank you very much. We confirm the fix of the problem.
    kind regard
    Michael

  • WebView: how to disable Touch support?

    Hi,
    I'd like to know if there is a way to disable the touch support for a WebView? Some JavaScript APIs detect this support as "active" and apply the "touch behaviors" on desktop machines.
    This is clearly a JS issue but I would appreciate if JFX could me to workaround this :-)!
    Thanks a lot.

    Please perform the steps as shown below if you are using Windows 7 Operating System
    Click Start -> in the Search box type: "Pen and Touch"
    Click "Touch" tab no top
    Disable checkbox for "User your finger as an input device"
    That's it. Touch should be disabled. Try poking your finger on the screen to test.
    Note: Please Click here for the steps if you are using Windows 8
    Hope this helps, for any further queries reply to the post and feel free to join us again
    "I work for Hewlett-Packard"
    * * * * * Click the "Purple Thumbs Up Icon in the lower right corner of a post" to say thanks * * * * *
    * * * * * Please mark Accept As Solution if it solves your problem * * * * *
    Regards,
    K N R K

  • Images not getting displayed in the WebView

    Hi every1,i am facing a problem in displaying images in the WebView. when a particular page or HTML is loaded in a WebView ,images are not coming and i am not able to go to other pages on clicking another link in that page. can ny1 help me?

    @ is a default value as per ALV internal process. This is used in icons .
    I think this is causing the confusion.
    Check in the fieldcat if there is any adjsutment to be made to handle this.
    Br,
    Vijay

  • MDB Timeouts and transaction behavior

    Hi, thanks in advance for any help with this.
    We have a MDB where we have set the timeout to five minutes. In a particular case this timeout is being reached but even though the MDB times out the transaction and sends the message for redelivery the original transaction that was processing the message continues until something happens from an application standpoint to cause that original transaction to complete. This means that we have the same message processed twice under these circumstances.
    I would have expected that if a transaction timed out that the transaction would have been terminated and therefore our processing would have stopped. Is there a way to force this behavior or do we have to put an alarm in our code and kill ourselves such that we never encounter the transaction time out?
    Thanks,
    Sue Shanabrook

    I should have mentioned that we are using container managed transactions.

  • Unexpected Behavior error while creating a connection in IDT

    Hi Everyone,
    I have created a connection on top of a database using ODBC.
    I could able to see the connection in IDT.
    I have mentioned the user name and pw correctly  and tried testing the connection and got the error "unexpected behavior"
    PFA error.
    what could be the reason? any idea?
    Thanks.

    I find this 32-bit vs. 64-bit ODBC somewhat confusing.  I know you aren't dealing with Crystal Reports, but this blog post does provide some clarity.  It has a link to this Microsoft knowledge base article from which I quote...
    A 64-bit version of the Microsoft Windows operating system includes the following versions of the
    Microsoft Open Database Connectivity (ODBC) Data Source Administrator tool (Odbcad32.exe):
    The 32-bit version of the Odbcad32.exe file is located in the %systemdrive%\Windows\SysWoW64 folder.
    The 64-bit version of the Odbcad32.exe file is located in the %systemdrive%\Windows\System32 folder.
    One other warning.  In my experience I have found that you cannot run both the 32-bit and 64-bit ODBC admin tools at the same time.  If you have one running and try and start the other one it will just bring up the one you already had running.
    To make sure I know which instance I am in at any give time I have created a dummy data source that corresponds to the instance; 32-bit or 64-bit.
    Let us know how it goes.
    Noel

  • Capturing DVCAM in FCP 6.0.2 and encountering strange capture behavior

    I have FCP 6.0.2 and OSX 10.5.2 and QT 7.3.1. I have been capturing several DVCAM cassettes using my Sony DSR-20 deck. Although I have done this countless times before in earlier versions of FCP, I am encountering some strange repetitive behavior. I am capturing 30 minute clips one at a time. When I use batch capture it will cue the tape up properly to the in point...and then start capturing until it gets to about 10-12 minutes in, and then capture unexpectedly stops, no dialogue box, the tape rewinds and starts capturing again from the original in point. On this second capture, the tape sails past the 10 minute mark and keeps going to the end of the 30 minute clip. It then stops, gives me the dialogue box that it has successfully captured. And it has.
    But every DVCAM tape I captured today exhibited the same behavior. Capture would be successful until about about 10 minutes in, then FCP aborts (no dropped frame message, no dialogue box) rewinds the tape back to the in point, tries again, and this time succeeds with the second pass capturing the entire clip. Note at the 10 minute mark there is no scene change or no camera start/stop.
    Have other users experienced this issue? And if so, is there a workaround or a possible patch forthcoming from FCP?
    Many thanks,
    John

    Yes, each tape has an in and out point defined. In my 6 years of editing with Final Cut and DVCAM tapes I've never encountered this issue before in the capturing process until now. I will have to see in future weeks with other captures whether this is an on-going issue or not, but at least I can capture for now.

  • Is there any way to add dynamic parameter in sql without breaking Server Behavior

    Hello, i'm building multiple language site.. i would like to know if there is possible way to add dynamic parameter in my query, without break the server behavior.
    For example:
    mysql_select_db($database_dxc_conn, $dxc_conn);
    $query_Recordset1 = "SELECT article.articleName, article.articleDesc FROM article";
    $Recordset1 = mysql_query($query_Recordset1, $dxc_conn) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    will become something like this:
    $additionalSQL=", article.articleName_en";
    mysql_select_db($database_dxc_conn, $dxc_conn);
    $query_Recordset1 = "SELECT article.articleName, article.articleDesc $additionalSQL FROM article";
    $Recordset1 = mysql_query($query_Recordset1, $dxc_conn) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    this is just an example, my real scenarion is far more complicated than this... however this kind of approach break the server behavior and force to do hand-coding...
    i would like to know if there's better way to do such thing like this...

    viktor.iwan wrote:
    Hello, i'm building multiple language site.. i would like to know if there is possible way to add dynamic parameter in my query, without break the server behavior.
    Server behaviors are simply bits of boilerplate code automatically generated by Dreamweaver. Editing the code doesn't "break" it (unless your edits are badly written). However, once you edit the code, Dreamweaver no longer recognizes it, so you lose the ability to drag recordset results from the Bindings panel.
    If you want to edit server behavior code, the best way to handle it is to lay out your page as you want, using the Bindings panel. Once everything has been done, only then edit the server behavior code.

  • Odd behavior when using custom Composite/CompositeContext and antialiasing

    Hi,
    I created a custom Composite/CompositeContext class and when I use it with antialiasing it causes a black bar to appear. I seems it has nothing to do with the compose() code but just that fact that I set my own Composite object. The submitted code will show you what I mean. There are 3 check boxes 1) allows to use the custom Composite object, 2) allows to ignore the compose() code in the CompositeContext and 3) toggles the antialiasing flag in the rendering hints. When the antialiasing flag is set and the Composite object is used the bar appears regardless of if the compose() method is executed or not. If the Composite object is not used the bar goes away.
    The Composite/CompositeContext class performs clipping and gradient paint using a Ellipse2D.Float instance.
    a) When the Composite is not used the code does a rectangular fill.
    b) When the Composite is used it should clip the rectangular fill to only the inside of a circle and do a gradient merge of background color and current color.
    c) If the compose() method is ignored then only the background is painted.
    d) When antialiasing is turned on the black bar appears, i) if you ignore the compose() method it remains, ii) if you do not use the Composite object the bar disappears (???)
    NOTE: the compose method's code is only for illustration purposes, I know that AlphaComposite, clipping and/or Gradient paint can be used to do what the example does. What I am trying to find out is why the fact of simply using my Composite object with antialiasing will cause the odd behavior.  Been trying to figure it out but haven't, any help is appreciated.
    Thx.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class TestCustomComposite2
    extends JFrame
    implements ActionListener {
        private JCheckBox useCompositeChk, useAntialiasingChk, useCompositeContextChk;
        private Shape clippingShape = new Ellipse2D.Float(100, 100, 100, 100);
        private MergeComposite composite = new MergeComposite();
        public TestCustomComposite2() {
            super("Test Custom Composite");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel cp = (JPanel) getContentPane();
            cp.setLayout(new BorderLayout());
            cp.add(new TestCanvas(), BorderLayout.CENTER);
            JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
            panel.add(useCompositeChk = new JCheckBox("Use Composite", true));
            useCompositeChk.addActionListener(this);
            panel.add(useCompositeContextChk = new JCheckBox("Use Composite Context", true));
            useCompositeContextChk.addActionListener(this);
            panel.add(useAntialiasingChk = new JCheckBox("Use Antialiasing"));
            useAntialiasingChk.addActionListener(this);
            cp.add(panel, BorderLayout.SOUTH);
            pack();
            setVisible(true);
        public void actionPerformed(ActionEvent evt) {
            useCompositeContextChk.setEnabled(useCompositeChk.isSelected());
            invalidate();
            repaint();
        private class TestCanvas
        extends JComponent {
            public TestCanvas() {
                setSize(300, 300);
                setPreferredSize(getSize());
            public void paint(Graphics gfx) {
                Dimension size = getSize();
                Graphics2D gfx2D = (Graphics2D) gfx;
                gfx2D.setColor(Color.GRAY);
                gfx2D.fillRect(0, 0, size.width, size.height);
                RenderingHints rh = null;
                if(useAntialiasingChk.isSelected()) {
                    rh = gfx2D.getRenderingHints();
                    gfx2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                Rectangle r = clippingShape.getBounds();
                //gfx2D.setColor(Color.GREEN);
                //gfx2D.drawRect(r.x, r.y, r.width, r.height);
                gfx2D.setColor(Color.YELLOW);
                gfx2D.fill(clippingShape);
                Composite oldComposite = null;
                if(useCompositeChk.isSelected()) {
                    oldComposite = gfx2D.getComposite();
                    gfx2D.setComposite(composite);
                gfx2D.setColor(Color.ORANGE);
                gfx2D.fillRect(r.x, r.y, r.width + 1, r.height + 1);
                if(oldComposite != null)
                    gfx2D.setComposite(oldComposite);
                if(rh != null)
                    gfx2D.setRenderingHints(rh);
        public class MergeComposite
        implements Composite, CompositeContext {
            public CompositeContext createContext(ColorModel srcColorModel,
                                                  ColorModel dstColorModel,
                                                  RenderingHints hints) {
                return this;
            public void compose(Raster src,
                                Raster dstIn,
                                WritableRaster dstOut) {
                if(!useCompositeContextChk.isSelected())
                    return;
                int[] srcPixel = null;
                int[] dstPixel = null;
                for(int sy = src.getMinY(); sy < src.getMinY() + src.getHeight(); sy++) {
                    for(int sx = src.getMinX(); sx < src.getMinX() + src.getWidth(); sx++) {
                        int cx = sx - dstOut.getSampleModelTranslateX();
                        int cy = sy - dstOut.getSampleModelTranslateY();
                        if(!clippingShape.contains(cx, cy)) continue;
                        srcPixel = src.getPixel(sx, sy, srcPixel);
                        int ox = dstOut.getMinX() + sx - src.getMinX();
                        int oy = dstOut.getMinY() + sy - src.getMinY();
                        if(ox < dstOut.getMinX() || ox >= dstOut.getMinX() + dstOut.getWidth()) continue;
                        if(oy < dstOut.getMinY() || oy >= dstOut.getMinY() + dstOut.getHeight()) continue;
                        dstPixel = dstIn.getPixel(ox, oy, dstPixel);
                        float mergeFactor = 1.0f * (cy - 100) / 100;
                        dstPixel[0] = merge(mergeFactor, srcPixel[0], dstPixel[0]);
                        dstPixel[1] = merge(mergeFactor, srcPixel[1], dstPixel[1]);
                        dstPixel[2] = merge(mergeFactor, srcPixel[2], dstPixel[2]);
                        dstOut.setPixel(ox, oy, dstPixel);
            protected int merge(float mergeFactor, int src, int dst) {
                return (int) (mergeFactor * src + (1.0f - mergeFactor) * dst);
            public void dispose() {
        public static void main(String[] args) {
            new TestCustomComposite2();
    }

    I got a better version to work as expected. Though there will probably be issues with the transformation to display coordinates as mentioned before. At least figured out some of the kinks of using a custom Composite/CompositeContext object.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class TestCustomComposite2
    extends JFrame
    implements ActionListener {
        private JCheckBox useCompositeChk, useAntialiasingChk, useCompositeContextChk;
        private Shape clippingShape = new Ellipse2D.Float(100, 100, 100, 100);
        private MergeComposite composite = new MergeComposite();
        public TestCustomComposite2() {
            super("Test Custom Composite");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel cp = (JPanel) getContentPane();
            cp.setLayout(new BorderLayout());
            cp.add(new TestCanvas(), BorderLayout.CENTER);
            JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
            panel.add(useCompositeChk = new JCheckBox("Use Composite", true));
            useCompositeChk.addActionListener(this);
            panel.add(useCompositeContextChk = new JCheckBox("Use Composite Context", true));
            useCompositeContextChk.addActionListener(this);
            panel.add(useAntialiasingChk = new JCheckBox("Use Antialiasing"));
            useAntialiasingChk.addActionListener(this);
            cp.add(panel, BorderLayout.SOUTH);
            pack();
            setVisible(true);
        public void actionPerformed(ActionEvent evt) {
            useCompositeContextChk.setEnabled(useCompositeChk.isSelected());
            invalidate();
            repaint();
        private class TestCanvas
        extends JComponent {
            public TestCanvas() {
                setSize(300, 300);
                setPreferredSize(getSize());
            public void paint(Graphics gfx) {
                Dimension size = getSize();
                Graphics2D gfx2D = (Graphics2D) gfx;
                gfx2D.setColor(Color.GRAY);
                gfx2D.fillRect(0, 0, size.width, size.height);
                RenderingHints rh = null;
                if(useAntialiasingChk.isSelected()) {
                    rh = gfx2D.getRenderingHints();
                    gfx2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                Rectangle r = clippingShape.getBounds();
                //gfx2D.setColor(Color.GREEN);
                //gfx2D.drawRect(r.x, r.y, r.width, r.height);
                gfx2D.setColor(Color.YELLOW);
                gfx2D.fill(clippingShape);
                Composite oldComposite = null;
                if(useCompositeChk.isSelected()) {
                    oldComposite = gfx2D.getComposite();
                    gfx2D.setComposite(composite);
                gfx2D.setColor(Color.ORANGE);
                gfx2D.fillRect(r.x, r.y, r.width + 1, r.height + 1);
                if(oldComposite != null)
                    gfx2D.setComposite(oldComposite);
                if(rh != null)
                    gfx2D.setRenderingHints(rh);
        public class MergeComposite
        implements Composite, CompositeContext {
            public CompositeContext createContext(ColorModel srcColorModel,
                                                  ColorModel dstColorModel,
                                                  RenderingHints hints) {
                return this;
            public void compose(Raster src,
                                Raster dstIn,
                                WritableRaster dstOut) {
    //            dumpRaster("SRC   ", src);
    //            dumpRaster("DSTIN ", dstIn);
    //            dumpRaster("DSTOUT", dstOut);
    //            System.out.println();
                if(dstIn != dstOut)
                    dstOut.setDataElements(0, 0, dstIn);
                if(!useCompositeContextChk.isSelected())
                    return;
                int[] srcPixel = null;
                int[] dstPixel = null;
                int w = Math.min(src.getWidth(), dstIn.getWidth());
                int h = Math.min(src.getHeight(), dstIn.getHeight());
                int xMax = src.getMinX() + w;
                int yMax = src.getMinY() + h;
                for(int x = src.getMinX(); x < xMax; x++) {
                    for(int y = src.getMinY(); y < yMax; y++) {
                        try {
                            // THIS MIGHT NOT WORK ALL THE TIME
                            int cx = x - dstIn.getSampleModelTranslateX();
                            int cy = y - dstIn.getSampleModelTranslateY();
                            if(!clippingShape.contains(cx, cy)) {
                                dstPixel = dstIn.getPixel(x, y, dstPixel);
                                dstOut.setPixel(x, y, dstPixel);
                            else {
                                srcPixel = src.getPixel(x, y, srcPixel);
                                dstPixel = dstIn.getPixel(x, y, dstPixel);
                                float mergeFactor = 1.0f * (cy - 100) / 100;
                                dstPixel[0] = merge(mergeFactor, srcPixel[0], dstPixel[0]);
                                dstPixel[1] = merge(mergeFactor, srcPixel[1], dstPixel[1]);
                                dstPixel[2] = merge(mergeFactor, srcPixel[2], dstPixel[2]);
                                dstOut.setPixel(x, y, dstPixel);
                        catch(Throwable t) {
                            System.out.println(t.getMessage() + " x=" + x + " y=" + y);
            protected int merge(float mergeFactor, int src, int dst) {
                return (int) (mergeFactor * src + (1.0f - mergeFactor) * dst);
            protected void dumpRaster(String lbl,
                                      Raster raster) {
                System.out.print(lbl + ":");
                System.out.print(" mx=" + format(raster.getMinX()));
                System.out.print(" my=" + format(raster.getMinY()));
                System.out.print(" rw=" + format(raster.getWidth()));
                System.out.print(" rh=" + format(raster.getHeight()));
                System.out.print(" tx=" + format(raster.getSampleModelTranslateX()));
                System.out.print(" ty=" + format(raster.getSampleModelTranslateY()));
                System.out.print(" sm=" + raster.getSampleModel().getClass().getName());
                System.out.println();
            protected String format(int value) {
                String txt = Integer.toString(value);
                while(txt.length() < 4)
                    txt = " " + txt;
                return txt;
            public void dispose() {
        public static void main(String[] args) {
            new TestCustomComposite2();
    }

  • Is Mail.app one of the "erratic" behavior apps with a reset system clock?

    I am hoping someone can help with a fine detail of mail.app (v2.1.3) behavior.
    I had an incident where an iMac sent out 200+ smtp hits a minute and was tossed of the network for presumed zombie spaming.
    I think I have actually tracked the problem to an unfortunate conjunction of circumstances that is actually innocent (if still annoying)
    Let me set up the story:
    1. This is a common use computer, so Mail is not configured (except that it is --I'll get to that in a moment) and
    2. Safari will invoke Mail when you click on an "email link"
    Mostly everyone just quits mail if they goof and click an email link.
    BUT some time ago at least one person invoked Mail and composed a message. This message, naturally, remained in the outbox ever since. That person learned that they can't send email that way, so ever since they just cmd-Q Mail.
    BUT Before this person learned, they walked through the mail-config and told mail to try hitting smtp.mac.com:"nonExistantUser".
    So that covers the lead-up. Two days ago, mail was invoked via a Safari link, BUT it wasn't quit, it was sent to the background.
    Where it undoubtedly tried to send the outbox repeatedly until it was kicked off the network.
    Here is what I don't understand:
    Under this scenario of a mis-configured .mac address, will mail repeatedly try and fail to smtp at the maximum possible rate?
    OR
    Is the one other factor I am about to describe responsible?
    The one other factor:
    The clock battery is dead and there was a power failure at 4am that day.
    The system clock reset to 1969.
    Of course, nobody reset it.
    Is mail.app one of the apps that the finder message warns "may behave erratically"?
    (a GROSS simplification) does it have a bit of code like:
    1 check time-of-last-send-mail-attempt
    check newest-item-in-outbox
    if newest-item more recent then last-send-attempt
    do send-mail and record time-of-last-send-mail-attempt
    and go to 1
    else wait X minutes and go to 1
    which, if the clock was mis-set to 1969 would always record a last-send-attempt prior to anything in the outbox and trigger a send loop.
    Does anyone know if either Mail is tenacious about sending to a bad .mac address, or gets ridiculous under this circumstance for bad-clock-set?
    Marc

    I am hoping someone can help with a fine detail of mail.app (v2.1.3) behavior.
    I had an incident where an iMac sent out 200+ smtp hits a minute and was tossed of the network for presumed zombie spaming.
    I think I have actually tracked the problem to an unfortunate conjunction of circumstances that is actually innocent (if still annoying)
    Let me set up the story:
    1. This is a common use computer, so Mail is not configured (except that it is --I'll get to that in a moment) and
    2. Safari will invoke Mail when you click on an "email link"
    Mostly everyone just quits mail if they goof and click an email link.
    BUT some time ago at least one person invoked Mail and composed a message. This message, naturally, remained in the outbox ever since. That person learned that they can't send email that way, so ever since they just cmd-Q Mail.
    BUT Before this person learned, they walked through the mail-config and told mail to try hitting smtp.mac.com:"nonExistantUser".
    So that covers the lead-up. Two days ago, mail was invoked via a Safari link, BUT it wasn't quit, it was sent to the background.
    Where it undoubtedly tried to send the outbox repeatedly until it was kicked off the network.
    Here is what I don't understand:
    Under this scenario of a mis-configured .mac address, will mail repeatedly try and fail to smtp at the maximum possible rate?
    OR
    Is the one other factor I am about to describe responsible?
    The one other factor:
    The clock battery is dead and there was a power failure at 4am that day.
    The system clock reset to 1969.
    Of course, nobody reset it.
    Is mail.app one of the apps that the finder message warns "may behave erratically"?
    (a GROSS simplification) does it have a bit of code like:
    1 check time-of-last-send-mail-attempt
    check newest-item-in-outbox
    if newest-item more recent then last-send-attempt
    do send-mail and record time-of-last-send-mail-attempt
    and go to 1
    else wait X minutes and go to 1
    which, if the clock was mis-set to 1969 would always record a last-send-attempt prior to anything in the outbox and trigger a send loop.
    Does anyone know if either Mail is tenacious about sending to a bad .mac address, or gets ridiculous under this circumstance for bad-clock-set?
    Marc

Maybe you are looking for