Confusing code code

Hi
Can someone explain to me what is happening with the following code:
   public void paint(Graphics g) {
       Graphics2D g2 = (Graphics2D)g;

It means casting the original Graphics object
into a Graphics2D object. It enables your application
to work in a Graphics2D 'enviroment'.

Similar Messages

  • [svn:sb-sherlock] 14394: Mostly code cleanup on AbcParser.java, some comments/minor changes on confusing code found elsewhere.

    Revision: 14394
    Revision: 14394
    Author:   [email protected]
    Date:     2010-02-24 13:47:35 -0800 (Wed, 24 Feb 2010)
    Log Message:
    Mostly code cleanup on AbcParser.java, some comments/minor changes on confusing code found elsewhere.
    Modified Paths:
        flex/sdk/sandbox/sherlock/modules/asc/src/java/macromedia/abc/AbcParser.java
        flex/sdk/sandbox/sherlock/modules/asc/src/java/macromedia/asc/parser/BinaryProgramNode.ja va
        flex/sdk/sandbox/sherlock/modules/asc/src/java/macromedia/asc/semantics/Builder.java
        flex/sdk/sandbox/sherlock/modules/asc/src/java/macromedia/asc/semantics/ConfigurationEval uator.java
        flex/sdk/sandbox/sherlock/modules/asc/src/java/macromedia/asc/semantics/FlowAnalyzer.java
        flex/sdk/sandbox/sherlock/modules/asc/src/java/macromedia/asc/semantics/ObjectValue.java

    Revision: 14394
    Revision: 14394
    Author:   [email protected]
    Date:     2010-02-24 13:47:35 -0800 (Wed, 24 Feb 2010)
    Log Message:
    Mostly code cleanup on AbcParser.java, some comments/minor changes on confusing code found elsewhere.
    Modified Paths:
        flex/sdk/sandbox/sherlock/modules/asc/src/java/macromedia/abc/AbcParser.java
        flex/sdk/sandbox/sherlock/modules/asc/src/java/macromedia/asc/parser/BinaryProgramNode.ja va
        flex/sdk/sandbox/sherlock/modules/asc/src/java/macromedia/asc/semantics/Builder.java
        flex/sdk/sandbox/sherlock/modules/asc/src/java/macromedia/asc/semantics/ConfigurationEval uator.java
        flex/sdk/sandbox/sherlock/modules/asc/src/java/macromedia/asc/semantics/FlowAnalyzer.java
        flex/sdk/sandbox/sherlock/modules/asc/src/java/macromedia/asc/semantics/ObjectValue.java

  • OpenCL freezes when trying to run kernel code

    Hi,
    I have some openCL kernel that runs through pixels stored in a frame buffer object, and counts non-black and non-white pixels. It used to run fine on my machine, but I believe that updates to Mac OS X and/or devtools might have caused a problem to cause it stall.
    The kernel object associated with the kernel code is attached to a QT window, and the kernel code is run n-times when the window requires an render update. This window is updated twice after it is created initially, which means that the sequence of openCL code does not cause problems initially. When I bring the window to the foreground, it requires another update and attempts to run the kernel code another n-times. But in the middle of those n-times, it stalls. i.e. if it needs to run 51 times, it stalls at iteration 26.  It appears that a call to clEnqueueReadBuffer causes a stall.
    I'm going to leave out details about why I use the openCL code unless it's absolutely necessary since that might confuse code. I thought it would be good to focus on the OpenCL code itself. Here it is for reference: http://dl.dropbox.com/u/10838242/forumsquestion.cpp
    Here's the gdb backtrace:
    #0  0x00007fff8e3a6122 in __psynch_mutexwait ()
    #1  0x00007fff8955ad9d in pthread_mutex_lock ()
    #2  0x000000010dd3acbd in gldFlushQueue ()
    #3  0x000000010bbc193f in IOAccelContextFinishResourceSysMem ()
    #4  0x000000010bbcd5b0 in gpumAcquireFenceOnQueue ()
    #5  0x000000010dd43fcd in gldCopyBufferDataWithQueue ()
    #6  0x00007fff8ffa7e2e in GCC_except_table49 ()
    #7  0x00007fff8ffc5f11 in clFinish ()
    #8  0x00007fff936800b6 in _dispatch_client_callout ()
    #9  0x00007fff93681723 in _dispatch_barrier_sync_f_invoke ()
    #10 0x00007fff8ffc5ddb in clFinish ()
    #11 0x00007fff8ffc25c2 in clSetEventCallback ()
    #12 0x00007fff8ffb86e6 in clEnqueueReadBuffer ()
    #13 0x0000000100020a31 in CLHandler::update (this=0x107683e20, tagged=@0x7fff5fbfb960, w=761, h=711) at clhandler.cpp:343
    #14 0x000000010002f8c1 in CustomBladesGLWidget::render (this=0x1072b09e0, indexMode=true, offset=135288, numPnts=4416, blobID=25, bladeIdsIntersected=@0x7fff5fbfb960) at customBladesGLWidget.cpp:943
    In the attached file, line 343 (bold above) corresponds to this call (in function CLHandler::update):
    //read data from buffer
      status = clEnqueueReadBuffer(cqueue,hitbuffer,CL_TRUE,0,mNumBladeCells * sizeof(float),mBladesHit,0,
                                   NULL,&event);
      handleError("clEnqueueReadBuffer","",status);
    Now, if I were to comment everything BELOW the initial call to clEnqueueWriteBuffer, it would stall at that function call instead. I have no idea why this occurs. Any help is greatly appreciated.
    If this problem is indicative of something more problematic then I guess Apple support might be one option.  System specs: MacbookPro 8,2, Core i7 2.2 GHz, AMD Radeon HD 6750M, OS X 10.8.2.
    Thanks

    Oh, I see, sorry, if it is legitmate, then ignore my post. My copy runs perfectly so I was wondering why yours did not. I understand that its a valuable computer, in fact, for the amount of money you payed for that mbp, you can build a computer of your own with state of the art components. Just saying. @sig, lets hope that he finds something on the support page to help him.

  • Socket Programing in J2ME - Confused with Sun Sample Code

    Hai Everybody,
    I have confused with sample code provided by Sun Inc , for the demo of socket programming in J2ME. I found the code in the API specification of J2ME. The code look like :-
    // Create the server listening socket for port 1234
    ServerSocketConnection scn =(ServerSocketConnection) Connector.open("socket://:1234");
    where Connector.open() method return an interface Connection which is the base interface of ServerSocketConnection. I have confused with this line , is it is possible to cast base class object to the derived class object?
    Plese help me in this regards
    Thanks in advance
    Sulfikkar

    There is nothing to be confused about. The Connector factory creates an implementation of one of the extentions of the Connection interface and returns it.
    For a serversocket "socket://<port>" it will return an implementation of the ServerSocketConnection interface. You don't need to know what the implementation looks like. You'll only need to cast the Connection to a ServerSocketConnection .

  • Confusing error building existing code on Solaris 10 Intel (AMD64)

    I have Solaris 10 on AMD64, using the bundled GCC
    gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
    I'm attempting to build part of our large C++ application and am getting a strange link error:
    ld: fatal: relocation error: file: ./obj_g/amd64-solaris10-gcc40/mksdic.o section: .rel.debug_info symbol: : relocation against a discarded symbol,
            symbol is part of discarded section: .gnu.linkonce.t._ZNK18CompressedADFSARep21get_transition_vectorEv
    collect2: ld returned 1 exit statusThe mangled symbol (containing ADFSARep) refers to a member function in the code.
    Googling for this error only returns hits on people attempting to bootstrap GCC itself, and comes down to an incompatibility between Solaris ld and GNU ld. From what I've read elsewhere the recommendation is to use GNU as but Sun ld, so I'm completely confused.
    Simple C++ programs work fine, of course. The executable in question uses several .o files as well as a number of static libraries. However, I can get a similar error if I construct a command-line that just links two of the object files without including any of the static libraries.
    I also tried with GCC 4.0.x, same result.
    Any and all help and suggestions are appreciated.
    Tom Emerson

    Try to ask your question in Solaris 10 x86 forum, since the question seems to be amd64 specific.
    Also, could you provide (if possible) those two c++ files source which object files fail to link along with the command line.
    As a side note, would you consider an option to migrate your project to SunStudio?

  • [svn] 3466: Refactored TransformOffset to reduce code and confusion.

    Revision: 3466
    Author: [email protected]
    Date: 2008-10-02 21:13:46 -0700 (Thu, 02 Oct 2008)
    Log Message:
    Refactored TransformOffset to reduce code and confusion.
    UIComponent and GraphicElement now aggregate an AdvancedLayoutFeatures object, which is responsible for computing the
    actual transform based on the layout properties and a CompoundTransform object passed in as a set of offset values.
    Re-enabled updateComplete events when component transform is modified, for mustella tests.
    Review: Glenn, Evtim.
    Modified Paths:
    flex/sdk/trunk/frameworks/halo-manifest.xml
    flex/sdk/trunk/frameworks/mxml-2009-manifest.xml
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/Path.as
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/graphicsClasses/GraphicElement .as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/core/UIComponent.as
    flex/sdk/trunk/tools/dependencychecker/frameworkSwcExceptionsList.txt
    Added Paths:
    flex/sdk/trunk/frameworks/projects/framework/src/mx/core/AdvancedLayoutFeatures.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/geom/CompoundTransform.as
    Removed Paths:
    flex/sdk/trunk/frameworks/projects/framework/src/mx/core/TransformOffset.as

    As far as creating this code goes, look up the % operator - it returns remainder. You could use it to find whether or not each number was a factor (for example, take all the numbers <= half of the given number - 24 - and perform a loop that uses the % operator to find if the remainder is 0, which would mean that the numbers were a factor), then use the sqrt method on applicable factors to determine if any of them are perfect squares.
    If you were wondering about the term referring to the creation of these factored numbers, I normally hear the process referred to as "factoring radicals" or "simplifying radicals."

  • I am so confused. I am thinking about buying an iPhone 4S but I want to use those card things that you can put the code in for the phone is this possible? I'm not talking about the 50$ unlimited card just the regular 20$ cards that hold mins and texts...

    I am so confused. I am thinking about buying an iPhone 4S but I want to use those card things that you can put the code in for the phone is this possible? I'm not talking about the 50$ unlimited card just the regular 20$ cards that hold mins and texts... As long as it has the support for the service it's hooked up to?

    As far as I know there is no US cell carrier that allows pay as you go with an iPhone. You can purchase an unlocked iPhone 4S at an Apple Store and try it with a non-supported carrier.

  • 30EA1: confusion in tab name holding PL/SQL code

    If I edit a PL/SQL function and use it as a starting point to create a similar one, the buffer/tab keeps the original name even after successful compilation of the new function. After refreshing the list of functions in the left-hand tree, the new function appears, yet clicking on the original one simply re-activates the similarly named tab, which now holds the code for the new function. That's pretty confusing, really.

    Fixed in EA3 (cannot remember if I checked EA2).
    The tree even automatically refreshes as soon as you compile your new function, great!

  • Long confusing lines of code.

    Whats the longest most confusing line of code you can think of...
    Very small Example:
    instead of
    int a = 7;
    double b = 14.0;
    int c = a - (int)b;
    int x = 1 + c;
    int y = 2;
    Point p = new Point(x,y);
    jScrollPane.getViewport().setViewPosition( p );it would be
    jScrollPane.getViewport().setViewPosition( new Point( 1 + 7 - (int)14, 2 ) );Well..you get the gist.

    ivGrossProfitPercentage = caseRetail.subtract(cost).multiply(new BigDecimal(100)).divide(caseRetail, GROSS_PROFIT_PERCENTAGE_DECIMALS, BigDecimal.ROUND_HALF_UP);This is only long and confusing because it's written in Java.
    If it were written in a language with proper decimal arithmetic, it would look like this:ivGrossProfitPercentage = (caseRetail - cost) * 100 / caseRetail;

  • HT201365 I recently upgraded my Ipadto 'iOS7', I carried out all the instructions,added a 4 digit code and after some confusion understood all the upgrades.

    I recently upgraded my Ipad to 'iOS 7' , after following the instructions and some confusion I added a 4 digit 'code' as requested. After getting used to all the new icons etc.the Ipad worked O.K.
    Later in the day when I switched it back on I was asked to enter my 'code' - which I thought I had done, but by mistake I entered my 'password'. after tapping 'done' the message ' iPAD Disabled' appeared.
    Please can anyone assist me? I am a OAP with limited computer experience.
    Mary Dunn

    If your device is disabled...
    Connect to your computer in recovery mode per the instructions in http://support.apple.com/kb/HT1212
    You may need to do this more than once.

  • Simple code, but confusing

    class C{
    static int f1(int i) {
    System.out.print(i + ",");
    return 0;
    public static void main (String[] args) {
    int i = 0;
    i = i++ + f1(i);
    System.out.print(i);
    }}When the above code compile and run, it give 0,1 (I am confused how?)
    when it pass the value its passing as 1 then the value should remain same when it returns zero.
    and it should be like i = 1 + 0;
    As per my idea it should give 1,1
    Can any one explain clearly how it works here ?

    PrasannA@java wrote:
    Hi all, thanks for the post
    Finally I got it what actually happening.
    If some one still not clear, can check the below link which explains in detail.
    [http://www.coderanch.com/t/244938/Programmer-Certification-SCJP/post-increment-confusion]
    That other thread doesn't explain much; the expression to be evaluated can be written as A+B where:
    A: i++
    B: f(i)
    Java evaluates this expression from left to right so,
    A: i++ has the value 0 while i has the value 1
    B: f(i) method f will be called with the value 1 (see A)
    B1: in method f the value of i is printed and 0 is returned
    B2: so the value of sub-expression B is 0
    Therefore the value of the entire expression is 0+0 == 0 which is printed next.
    Therefore the entire output will be 1,0
    kind regards,
    Jos

  • Im really confused. My ipod was giving the 13019 error message. I followed the steps, and it stopped giving me the error code but my music wont appear on my ipod. Any suggestions?

    Im really confused. My ipod was giving the 13019 error message. I followed the steps, and it stopped giving me the error code but my music wont appear on my ipod. Any suggestions? Please help

    Are you saying that the "Music" app is not present on your iPod Touch? Perhaps there is an issue with the restrictions on the iPod? If you're absolutely sure that the Music app is not present I would consider creating a backup of your iPod after syncing it with iTunes. I would then consider restoring it if this is the case.

  • Itunes crashed and I have all my music on my Ipod and computer in files that will not all open, that is irreplacable. I do not remember ever using a encyrtion code so I am confused on saving my music.what do I do?

    Very Frustrated and Wasted Money Please Help Me...... Itunes crashed and all of my libraries would not download, the songs that did came back 3/4 times which caused me to put everything on my new Hard Drive,I am have a bunch of files and libraries from Itunes with music that will not upload back to Itunes and I have a bunch on my IPOD that is irreplacable....On top of all these this I do not remember my encryption code but never remember locking it either. Please tell me what to do to save my music or reset the code and do a new one and how do I save this music,I see it on my library when I plug it up.Also what file do I look for for all the purchased music I had? Also my Remote acts up which never happened to me as well...

    What do you mean by encryption code?
    - Do yu mean the for some reason when you want to restore from backup iTunes asks for the password?
    - Do you mean that it has a screen-lock passcode and you do not remember the passscode?
    Please provide more clear information. I do not really understand your poblem. I can't tell whee the music is, or what will not "upload".

  • A confusing piece of code, may be food for thought.

    Looking at the following code it seems very obvious to me that the output should be 1010 but it turns out to be 2020. Could anybody explain the reason behind it?
    public class TestClass
      public static void main(String args[ ] )
        TestClass tt = new TestClass();
        tt.ww();
      public void ww()
        Base b = new Base();
        Base b2 = new Base();
        b.iAge = 10;
        b2.iAge = 20;
        System.out.print(b.iAge);
        Integer iw = new Integer(b.iAge);
        col(iw);
      public static void col(Object o)
        Integer iw = (Integer) o;
        System.out.print(iw.intValue());
    class Base
      public static int iAge;
    }

    Considering that the iAge member is 'static' (only one copy no matter how many instances of the object), and that you last set it to 20 before you output anything, what's to wonder about?

  • Am confused at this PostFix Operator code, pls help.

    Hi all,
    pls chk this piece of code:
    public class Program {
    public static void main(String[] args) {
    int i = 0;
    for (int j = 0; j != 10; j++) {
    i = i++;
    System.out.println(i);
    Its output is 0, can someone pls give a detailed explanation.
    Thanx in advance.

    I used the double quotes to indicate a literal value,
    isn't that the usual way to express that in ordinary writing?
    http://onesearch.sun.com/search/onesearch/index.jsp?qt
    =i+%3D+i%2B%2B%3B&subCat=siteforumid%3Ajava31&site=dev
    &dftab=siteforumid%3Ajava31&chooseCat=javaall&col=deve
    loper-forumsThis is surreal ;-)
    kind regards,
    Jos

Maybe you are looking for

  • How to change the language from French into English in Photoshop CC in Creative Cloud

    Hi, I recently took a subscription for Creative Cloud (LR5 and Photoshop CC). I live in France but I am more used to English terminology and I'm currently doing Photoshop as e-learning on an American forum. (I'm not French). I managed to change the d

  • Capital One Secured Card Changing

    I just had a long conversation with a Capital One CSR. I originally called to ask about the Credit Steps program on my new QS1 ($1k CL) and then asked about my existing Secured card ($99 dep for $300 Dec'14 -> $200 deposit -> $500 deposit -> $300 CLI

  • Imported Archives - Path

    Hi, Someone know where PI deploys the imported files? Example a JAR file. Thank you very much. Angelo

  • Loading modules when using enter-pssession

    Hello I see some thing that appears unusual to me. Server1 is running PowerShell v2 Client1 is running PowerShell v2 If I am logged directly to Server1 and do $Host $PSVersionTable I get the result I would expect e.g. version 2 and PSVersion2. I can

  • Acrobat 8 quitting unexpectedly upon manual quit

    I'm running Adobe Acrobat 8.1.2 on Mac OS 10.4.11 with plug-ins for Fusion Pro, PitStop, and Kodak Prinergy. Every time I quit Acrobat, instead of quitting normally and saving all of my settings, it gives me a "the application Acrobat has quit unexpe