How to implement the observer model?

Hello guys,.

I have some problems with the implementation of the model of the observer. So I m making a good app and I put a meter change with volume.

I have already designed counter and the volume is calculated.

So I have a class called Application (is the main class) and this class have the application designer, makes the audio capture and calculate the volume.

And I have the MeterMic class and in this class, I have the graphic meter where I send this graphic multimeter to the application via JPanel.

In MeterMic I have the variable 'value' and this variable will make the changes in the bars of the counter and I want equal to the value of the volume of the application. I try referencing the Application object, but does not have the value of the volume.

So, I want to implement the model of the observer.

I need to observed the variable volume and the volume changes I want to send this change of variable value in MeterMic.

My problem is: who is the observer and observed? And what I need to do to implement the model.

My best,
David

DavidHenriques wrote:
Thanks for the help guys. People really nice here in the forum.

So be sure to mark this thread as a response.
~ and reward of points ofcause... ~.
(o).

Good bye
DPT

Tags: Java

Similar Questions

  • How to implement the ScreenUiEngineAttachedListener Interface?

    How to implement the ScreenUiEngineAttachedListener Interface? It is somewhat a mystery reading through the API.

    I have a class that implements ScreenUiEngineAttachedListener:

    public class UiListener implements ScreenUiEngineAttachedListener {
      public void onScreenUiEngineAttached(Screen screen, boolean attached) {
      }
    }
    

    Then I have a class MyScreen which extends from screen and has two methods:

    public void addScreenUiEngineAttachedListener(ScreenUiEngineAttachedListener listener) {
      super.addScreenUiEngineAttachedListener(listener);
    }
    
    private void removeScreenUiEngineAttachedListener() {
    
    }
    
    • What is the correct positioning of everything?
    • Can I define an instance of UiListener and pass in the addScreenUiEngineAttachedListener?
    • How to remove UiListener in removeScreenUiEngineAttachedListener?

    You will need:

    • an instance of your UiListener - probably a static member inside your UiApplication;
    • a method that allows to retrieve the reference to this instance of UiListener;
    • a call in your constructor for the screen at addScreenUiEngineAttachedListener (yourApplication.getUiListener ()) or similar;
    • potentially a call within your onScreenUiEngineAttached (attached screen, boolean) routine, the branch (attachment is false) : screen.removeScreenUiEngineAttachedListener (this);

    However, all this is too much work for no gain. Just override protected void onUiEngineAttached (boolean attached) in your screen class and make your logic there - all members of your class are accessible and all the code is placed where it belongs.

  • How to get the device model, for example app works on PlayBoook or BlackBerry 10?

    How to get the device model, for example app works on PlayBoook or BlackBerry 10?

    You can use this class: http://goo.gl/GtMLP for information on devices

    something like this:

    String myDeviceModel = android.os.Build.MODEL;
    String myDeviceBrand = android.os.Build.BRAND;
    String myDeviceDevice = android.os.Build.DEVICE;
    
  • How to implement the SOA 11 g limitation?

    Hi all

    Can someone tell me how to implement the limitation in SOA to create a repository for the history of the transactions?

    ARO

    Hari

    Hello

    By Greg Mally of Oracle message covers an approach to the limitation in SOA Suite

    https://blogs.Oracle.com/soacommunity/entry/throttling_in_soa_suite_via

  • Is there anyone who knows how to implement the P3 Colorspace in first CC2014?


    Is there anyone who knows how to implement the P3 Colorspace in first CC2014?

    Hi RVBBernard,

    Sorry, there is currently not available in Premiere Pro. You can request a feature here: http://adobe.ly/feature_request

    Thank you

    Kevin

  • How to implement the AdSense code

    Hello

    I don't know how to implement the code.

    Can someone help me?

    Hello

    Please take a look on the link adobe form at the address below. This could help you.

    https://forums.Adobe.com/message/4325647

    Kind regards

    Nitin Kapila

  • HOW TO CREATE THE WINDOWS MODEL

    Dear all

    I'm new to the ESX Server do not know how to create the window model in EX Server I mean customer infrastructure. So that I can do a lot of copy of windows from this model.

    Kindly help me to solve my problem step by step.

    Thank you

    Malik Adeel Imtiaz

    NetSol Technologies

    Hello

    Create a new virtual machine in Virtual Center - install the software updates that you need in this model etc etc.

    Click right of the virtual machine when you finished and chose "convert model', if you need later update it is again you can 'convert virtual machine' and update before make you a model again.

  • How to debug the RTF model

    Hi all

    How to debug the RTF model, we had an error during the creation of the report...

    Thanks in advance.

    Hello

    Check out the link below, it may be useful for you

    http://bipconsulting.blogspot.com/2010/01/bi-Publisher-logging-debugging-part-4.html

    Thank you
    Ananth
    http://bintelligencegroup.WordPress.com/

  • How to implement the process Train in Jdev 10.1.3

    Hello..
    Anyone know where to find a tutorial on how to implement the process train in jdev 10.3.1

    Thank you

    http://download-West.Oracle.com/docs/HTML/B25947_01/web_complex005.htm#CEGIGJID

  • How XAI implements the 'do more' function in CC & B pages

    Hi all
    There is a button "get more" in CC & B page if you put more than 50 recordings, just by clicking on the button when I want to get the latest recordings, but how do I implement the same function by XAI, I studied a lot of time on this problem and got nothing. so, everyone here had encounterd the same question? and resolved?
    any help would be appreciated.

    The GET more feature works in the browser because there is a separate servlet 'list' that retrievs data. It is based on some data to the HTTP context for correct operation. Unfortunately the 'do more' function is not supported by the Servlet XAI (it does not on the context HTTP data). Your only option is to roll your own mechnaism of paging for the data that you need.

    The model is going to like it...

    1. develop SQL code for what you want to paginate
    2. create a new "Listings Service" class that acts as a underlying service
    3 mark the service with entries include the size of the page and you want to retrieve the page number
    4. annotate the service with a list of data that will be returned
    5. use the page size and page number to create and run the query, and build the result
    6 enter the service as a Service of inbound XAI
    7. deploy the code
    8. test using dynamic presentation

    for example. Here is one more example for the search values...

    import com.splwg.base.api.BusinessEntity;
    import com.splwg.base.api.SimpleEntityList;
    import com.splwg.base.api.service.DataElement;
    import com.splwg.base.api.service.ItemList;
    import com.splwg.base.api.service.ListBody;
    import com.splwg.base.domain.common.lookup.LookupField_Id;
    import com.splwg.base.domain.common.lookup.LookupValue;
    import com.splwg.base.domain.common.lookup.LookupValue_Id;
    import com.splwg.base.support.service.metainfo.ListBodyField;
    import com.splwg.shared.environ.ServiceListConstant;
    import com.splwg.shared.logging.Logger;
    import com.splwg.shared.logging.LoggerFactory;

    /**
    *
    * @author edhoi
    @ListService (name = CmGetMoreListValues, size = 10000, = CMLGETMRL, CMLGETMRL = service program,
    * body = @DataElement (content = {@DataField (name = METER))
    ({*, @RowField (entity = ValRech, name = ValRech)});
    * headerFields = {@DataField (name = ELEM_SIZE)
    *, @DataField (name = FIELD_NAME)
    ({*, @DataField (name = FIELD_VALUE)})
    */
    SerializableAttribute public class CmGetMoreListMaintenance extends CmGetMoreListMaintenance_Gen {}

    public private static final logger LOG = LoggerFactory.getLogger (CmGetMoreListMaintenance.class);
                   
    @Override
    protected {readList()} ItemList

    Call CmGetMoreBusinessComponent
    CmGetMoreBusinessComponent cmGetMoreBusinessComponent = CmGetMoreBusinessComponent.Factory
    . newInstance();
    LookupField_Id lookupField_Id = new LookupField_Id (getHeader () .get)
    CmGetMoreListMaintenance.STRUCTURE.HEADER.FIELD_NAME));
    LookupValue_Id lookupValueId = new LookupValue_Id (lookupField_Id,
    getHeader () .get)
    CmGetMoreListMaintenance.STRUCTURE.HEADER.FIELD_VALUE));
    BigInteger pageSize = getHeader () .get)
    CmGetMoreListMaintenance.STRUCTURE.HEADER.ELEM_SIZE);
    ValRech lastValue = lookupValueId.getEntity ();

    The list of values = cmGetMoreBusinessComponent
    .getLookupValuePageData (lookupField_Id, lastValue, pageSize
    (. intValue());

    long count = cmGetMoreBusinessComponent
    .countLookupValues (lookupField_Id);

    If (values.size () > 0) {}
    lastValue = values.get (values.size () - 1);
    } else {}
    lastValue = null;
    }
              
              
    ItemList itemList = new ItemList(CmGetMoreListMaintenance.STRUCTURE.list_CmGetMoreListValues.name);
              
    ListBody listBody = itemList.newListBody ();
         
              
    listBody.put (CmGetMoreListMaintenance.STRUCTURE.list_CmGetMoreListValues.COUNTER, (BigInteger) new
    Long.toString (count)));

    If (lastValue! = null) {}
    listBody.put (CmGetMoreListMaintenance.STRUCTURE.list_CmGetMoreListValues.FIELD_VALUE, lastValue.getId () .getFieldValue ());
    }
              
    for (ValRech value: values) {}
                   
    Data listElement = itemList.newDataElement ();
    listElement.addRow (value.getDTO ());
                   
    }
              
    return itemList;
    }
         
    @Override
    protected void afterPopulateList_CmGetMoreListValues)
    ItemList targetList, SimpleEntityList sourceList,
    BusinessEntity sourceListParent) {}
    TODO self-generating method stub
    super.afterPopulateList_CmGetMoreListValues (targetList, sourceList,
    sourceListParent);
    }
         
    }

  • How to implement the reading of data from a matte file on a cRIO?

    Hi all!

    I'm still not sure, it is plausible, but I'll ask rather before you begin complicating. So far, I found no useful information on reading in the data to a device of RT from a file (type of a simulation test - data is simulated).

    I have the MatLab plugin that allows the storage of data read a MAT file, which has a number of columns that represent the different signals and lines representing the samples at a time (depending on the time of the sample - sample every time has its own line of signal data).

    I have no idea how to implement this at cRIO.

    The idea is:

    I have some algorithms running on the controller of RIO in a timed loop. As the entries of these algorithms I need to access each of the values of columns in the row, which is the time of the sample (sort of a time series - without written actual times).

    I am fairly new to RT and LV development, so any help would be appreciated.

    Thank you

    Luka

    Dear Luka!

    I think the reading of all the samples in a single channel is exactly what you need here, because reading the files may take some time and is not deterministic, so it is best to read all the data in memory (or if this is not feasible due to problems of size, fairly large pieces may be sufficient). The table read can be provided and then in the loop simulating outings, something like this:

    I used here separate channels so it's more graphic, but you can build all the channels in a 2D array and array index corresponding to the samples fom 1 who. You can also use for loops with indexing as tunnels are setup and then you won't need the index functions and the number of iterations is also set automatically, but you have to take care of synchronization settings.

    Best regards:

    Andrew Valko

    National Instruments

  • How to implement the wafer map using LabVIEW?

    Hello LabVIEW Masters!

    I have a project which includes control and searching for information on a PROBER. One of the difficulties I have now is how to implement a WAFER card using LabVIEW. According to the requirements of my client, the element of pads varies between 6 k and 23 k. I guess that do everything (a = a ctl/indicator led) will be a hell of a task, especially on how to effectively manipulate each elements. Does anyone have a better idea on the way whose that?

    Please, I seriously need your help...

    Thank you and best regards,

    Dennis DG

    Hi Dennis,

    This wafer GerdW post card appears to me as a sort of histogram (for example http://www.ni.com/white-paper/4158/en#toc3);

    Altenbach post well this example that shows how to use a plot of intensity to create a 2d histogram:

    http://forums.NI.com/T5/LabVIEW/overlay-plots-as-intensity-graph/m-p/211222#M119248

    Learn how it works and try to adapt it to your specific task.

    Alex

  • How to run the callback model SequenceFilePostStepFailure after step fails with the calls of the nested sequence

    Hello

    I want to appear a message immediately box on any test failure.  I thought I could use the reminder of the SequenceFilePostStepFailure model to achieve this, but when I change the reminder of process model to achieve this, I found that the recall code is executed only for the failures of step of the top level of the page sequence file.

    My test code has sequence called before mutiple files to the granularity of the basic numerical limit test that range from success or failure, so I would like to run the callback SequenceFilePostStepFailure immediately at this level.  I can accomplish this by adding a substitution of recall of SequenceFilePostStepFailure in the file of the sequence in question, but I prefer to use the implementation of reminder default template, so I can't find all the places where numerical limits tests are executed and cause the ASE of pass/fail.

    I have attached a few sequences of the example I want to illustrate the problem.

    Thanks for the help,

    Daniel

    My fault, I see now that the recall of model should I have changed is the ProcessModelPostStepFailure.  Problem solved.

  • How to implement the management of the application users?

    I need to know how to add the possibility of application to create, modify, or delete user by user accounts manager [I count special wolud create in application]? I want to create the solution that includes 5 departments and each Department has few users. If the user is in Group would be pages prepared for the Group's engineers, tabset if user is in Group accountants would be a tabset prepared for accountants, etc. etc. Ability to create, modify, or delete user accounts must be implemented for manager who should be able to move users between groups if necessary.

    Duplicate thread: Manage users in the application

    Please close this message and continue the original discussion.

  • How to implement the logic below?

    Hi friends,

    Greeting of the day!

    I have a table with the following columns

    STUDY_NAME
    COUNTRY
    STUDY_SITE
    DISCREPANCY_ID
    REVIEW_STATUS
    COMMENT_TEXT


    I would like to implement the following logic on the table of the table


    logic: I need to extract all the columns in the table above with the following condition,.

    If the COMMENT_TEXT begins with 'CCRA Query' or 'ARC Central' and the REVIEW_STATUS is Review_Status 'ARC Review' = 'CCRA Review' if Review_Status = Review_Status.

    Thanks in advance

    Please give entered how implement the foregoing

    Use CASES

    case when (
                    COMMENT_TEXT like 'cCRA Query%' or
                    COMMENT_TEXT like   'Central CRA%'
                )  and  REVIEW_STATUS = 'CRA Review'
                    then 'cCRA Review'
           else  Review_Status
    end as  Review_Status
    

Maybe you are looking for