Determine the size of the component during execution

I am trying to build a component Paginagion of size fixed. The number of pages which means that the size of the paging is fixed, however depending on the content may vary. Most do not specify how much is displayed on a single page.

The idea is to use the text as input and push as much as can be displayed on the page. Factors having an influence here is the fonts and formatting.

To determine the page which you should see that I need to understand the amount of text that can be displayed. To do this, I need to know the size of the element that contains the text (think label). The size of the label is however only determined after that is layouted. So here's what I could do:

    @Override
    public void start(Stage primaryStage) {
        Label lbl = new Label("uitroweigudfgf jkfhgklfsjghslkghs kflgskjgh");
        System.out.println(lbl.getWidth()+","+lbl.getHeight());
        lbl.widthProperty().addListener(new ChangeListener<Number>(){
            @Override
            public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
                System.out.println(lbl.getWidth()+","+lbl.getHeight());
            }
        });
        lbl.heightProperty().addListener(new ChangeListener<Number>(){
            @Override
            public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
                System.out.println(lbl.getWidth()+","+lbl.getHeight());
            }
        });
        StackPane root = new StackPane();
        root.getChildren().add(lbl);
        
        Scene scene = new Scene(root, 300, 250);
        
        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
   }

After the third change, I have the dimensions of the label. With this method, I would have to push all of the text in labels to figure out what can be displayed.

Is there a better way to do it?

My basic problem was with the size of the labels. Try to find a solution I had a look at LabelSkinBase which uses the Utils class in the same package. This class provides methods (although private package) to calculate the size of the text that results from:

static Text helper = new Text();

static double computeTextWidth(Font font, String text, double wrappingWidth) {
  helper.setText(text);
  helper.setFont(font);
  // Note that the wrapping width needs to be set to zero before
 // getting the text's real preferred width.
  helper.setWrappingWidth(0);
  helper.setLineSpacing(0);
  double w = Math.min(helper.prefWidth(-1), wrappingWidth);
  helper.setWrappingWidth((int)Math.ceil(w));
  return Math.ceil(helper.getLayoutBounds().getWidth());
}

static double computeTextHeight(Font font, String text, double wrappingWidth) {
  return computeTextHeight(font, text, wrappingWidth, 0);
}

static double computeTextHeight(Font font, String text, double wrappingWidth, double lineSpacing) {
  helper.setText(text);
  helper.setFont(font);
  helper.setWrappingWidth((int)wrappingWidth);
  helper.setLineSpacing((int)lineSpacing);
  return helper.getLayoutBounds().getHeight();
}

static int computeTruncationIndex(Font font, String text, double width) {
  helper.setText(text);
  helper.setFont(font);
  helper.setWrappingWidth(0);
  helper.setLineSpacing(0);
  // The -2 is a fudge to make sure the result more often matches
  // what we get from using computeTextWidth instead. It's not yet
  // clear what causes the small discrepancies.
  Bounds bounds = helper.getLayoutBounds();
  Point2D endPoint = new Point2D(width - 2, bounds.getMinY() + bounds.getHeight() / 2);
  return helper.impl_hitTestChar(endPoint).getCharIndex();
}

With that, I am able to determine the amount of text can be put into the label, without the chain of ellipsis appears.

Tags: Java

Similar Questions

  • change the frequency of the signal during execution

    Hi, I'm working on a VI to calculate excess of signal I think VI seems to be good (not sure) but now my problem is

    change the frequency during execution, which I am not able to do only when I stop and run the vi frequency changes... pls

    someone help me I tried to put in an event... but no use... maybe iam missing something pls help me...

    I noticed that you have some time a loop around the entire block diagram - I'm not entirely sure why that is.  The way you have your VI wrote that the two inner loops will never come out unless there is an error-'stop' buttons are hidden.  Thus, the outer loop is not do anything for you.

    Once you take it, it is easy to see why you cannot change frequency.  It is defined once, outside of the loops and so never gets checked again.  The best way to resolve this, in your case, is to use registers with shift on the upper loop and check if the value of the frequency has changed since the last iteration.  If so, generate a new waveform and feed DAQmx writing instead.

    See the version annexed to your main VI for what I mean.  (I also replaced the controls to stop with one that is visible and which will stop the two loops without your duty to hit the button abandon.) I'm also an error on the DAQmx read in the loop at the bottom, but I'm sure it will work fine on your equipment.

    See you soon,.

    Michael

  • Pass the value of the variable during execution

    Hello

    I have a package with a set of interfaces and three other variables.

    I want to pass the value of the variable at runtime, based on the value passed I want to decide which interface to run then. How can I do this? I got a set variable but I want to asssign the value during execution.

    Any help is greatly appreciated.


    Thank you
    San

    You have many options to achieve this goal.

    1. keep the run settings in the database, extract the Variables in a time of refreshment and use these variables in your Interfaces to get values of execution.

    2. change the value to the variables on the outside. You can declare a variable in a package as a step of the statement, and then use the variable in your interface in a successive step in your package. Then, create a scenario of your package and creating the scenario, it will prompt you to include the variables that you want to include as a startup parameter. Choose the one (s) concerned. Citing this scenario using Java or an OdiStartScen command or by using Webservices ODI externally, you can provide values of the runtime as a result.

    I hope this helps.

    Concerning
    A

    Published by: 922636 on August 29, 2012 23:53

  • definition of the background image of the file during execution

    So, I have another issue to resolve and my migration to 11.5 will be complete.  In the previous iteration, the project has been able to set the background image from an external file dynamically during execution.

    After the migration, it seems that the projector keeps the canonical path to the image of Member and looking for him there. In other words, loads of projector, but a file finder opens, saying: he cannot find the background image in the path of the source machine Director.  Setting the name of the file in the jargon does not stop this behavior doesn't happen.

    I tried to re - import the image as "link to external file" (which had the same results) and flat import (which does not load the file during execution, even if I put the file name in the jargon).

    Anyone know how I can do this, the value of the background image of a file during execution?

    Thanks in advance!

    I do it all the time.  Just make sure that the image is in the same location relative to the projector that's director file.  The easiest way is of course if the image is in the same folder as the .dir file, in which case, you'd sure as to put it in the same folder as the projector, and you can set the name of the file using:

    Member ("someExternalMember"). FileName = the moviePath & "filename.jpg"

    You can have it in subfolders as well if you want to make sure that the relative location is the same.

  • Adding series to the table during execution?

    Newbie :-)

    I'm trying to add series to a chart during execution because the number of series to draw is variable and only determined once the XML of a HTTPService returns...

    My chart looks like this:

    < mx:PlotChart id = "mainChart" showDataTips = "true" width = "100%" height = "100%" >
    < mx:series >
    ...

    If I add:

    < mx:PlotSeries xField = "Size" yField = "CompetitorPrice" displayName = "Competitor price" / >

    then the data plots OK, but try to create the same AS serial does not work (nothing appears):

    var newSeries:PlotSeries = new PlotSeries();
    newSeries.xField = "size";
    newSeries.yField = "CompetitorPrice";
    newSeries.displayName = "SeriesAddedAtRuntime!"
    mainChart.series.push (newSeries);

    Debugging presents the new series added and it seems OK... but it does not appear on the graph. No errors.

    I tried mainChart.executeBindings (); and mainChart.validateNow (); with no chance, but I guess as to what is to be the case here, as you can probably!

    What Miss me something to force an update of the chart with the new series added?

    Thanks in advance

    John

    It is not displayed because the table is not aware of the change in ownership of the series. I think that to run the following steps (give an or take a few syntax errors):

    var set = mainChart.series;
    var newSeries:PlotSeries = new PlotSeries();
    ...
    Series.push (newSeries);
    mainChart.series = series;

  • Edit/delete/add scene coordinates in the table during execution

    Hello world

    I managed to build table allows you to store and record the coordinates of the stage and remind to control steps. However, I need change/remove/add details of scene during execution. I also need to allow the user to directly edit the coordinate from the scene of the array. Wondering what someone knows what is the best way to do it? Or is it better to use the matrix or Cluster? Thanks in advance.

    Best regards

    Han Yen

    Han Yen wrote:

    Thanks much altenbach for all the advice. I tried to do a table 2D control. I've been playing with table in the control. However, I still can't find out how can I detect that I change the data in the table 2D with the more recent issue during execution? How can I then update my current table with the latest data?

    Well, the 2D table is updated immediately and you do not all the other tables.

    Do you mean that you want to update XAbs, etc. where the just changed line is already selected?

    In any case, here's a simple project, perhaps it will give you some ideas. I would recommend using also the tables for XYZPos, entrances etc. and the XYZabs. This simplifies the code because you reduce the number of terminals and table operations.

    Let me know if something is not clear to you.

  • Problem with pl/sql procedure, trying to get the value of the user during execution

    Hello

    Using oracle 11.2.0.3

    Can run sql that gets the value of the user during the fine workmanship and also via an anonymous block.

    uses of SQL & Enter_Product_Number

    anonymous block using: Enter_Product_number.

    However, get problems when trying to create a pl/sql procedure, use one of the above

    relevant below tried code part & and: buit works do not error, try bad bind variable if used: and ora-600 if try use &.

    How can we have a procedure from pl/sql that can call and receives a value of user during execution?

    Only way around what I can think of is to pass parameters to the procedure

    Thank you

    create or replace procedure ins_into_issues is

    v_nd_rec_cnt number (10);

    v_normal_rec_cnt number (10);

    Start

    Select count (*)

    in v_nd_rec_cnt

    refmast.issues I have

    where i.iss_product_num = & old_nd_product_number;

    Select count (*)

    in v_normal_rec_cnt

    refmast.issues I have

    where i.iss_product_num = & normal_product_number;

    -code below commented above works.

    end;

    Hello

    what something like this:

    create or replace procedure INS_INTO_ISSUES ( in_normal number, in_old number )  is
      v_nd_rec_cnt     number(10);
      v_normal_rec_cnt number(10);
    begin
        select count(*)
          into v_nd_rec_cnt
         from refmast.issues i
         where i.iss_product_num = in_old;
      --
        select count(*)
          into v_normal_rec_cnt
          from refmast.issues i
         where i.iss_product_num = in_normal;
    end;
    

    concerning

    Kay

  • Filter the Table during execution and keep uncommitted line changes

    Hello

    I have a requirement which has been quite difficult for me so far.

    I use the first version Jdev 12 c.

    I have a table of AF that is connected to a ViewObject that is used for sending new data.

    When I add lines to this ViewObject, I put a field that I intend to use for filtering so that the number of lines is not displayed at the same time.  This field comes from a selection of LOV.

    I want to be able to change lines are displayed in the table based on what is the current value of selection LOV.  This isn't a problem for me, and it works perfectly using a view criteria and a variable transitional EO I put in place.

    My problem is that when I select a new value in the LOV and change to bind the variable view criteria, I want all changes uncommitted to the lines to be preserved in the View object.  Currently, the lines are not keep their changes, and I need to do this, because after that the user has entered data for a large number of lines, there will be a commit to the database for all new lines added.  Is this possible or should I look for an alternative?

    I also tried to use a table filter in the link of the page layer, but I get an error that I can't debug. It is marked as Houston-34014.  In this method, I try to access my bean in pageFlowScope to filter the table.  This bean variable is updated when the LOV selection changes.  Error messages settings are {0 = oracle.jbo.Key [-220-225], 1 = root}.  I also read that this filter parameter is a static filter and does not dynamically during execution.

    Any help would be appreciated, thanks for reading.

    Hello lhymel

    I think that your problem is solved, so please close this thread and open a new thread for tuning related problem

    Thank you

    -Ashish

  • How to add the option in the SelectItem during execution

    Hello
    Can anyone help me please with this use case?

    I have a list set to the managed bean as below. I want to add new LOV in list (DROP DOWN 2) "ZZZ" based on the value selected in the DROP DOWN 1 on the same page. So that particular one value selected in the DROP DOWN 1, I want to have this new LOV displayed in the DROP DOWN 2. I'm doing it through ValuchangeListener, but I'm not able to find how to add the LOV. Help, please.



    USER INTERFACE
    <!-- DROP DOWN 1 -->
    <af:selectOneChoice label="Order Type" id="soc2" required="true"
                                            validator="#{lovManagedBean.orderTypeValidator}"
                                            binding="#{userAuthentication.orderType}"
                                            autoSubmit="true"
                                            valueChangeListener="#{lovManagedBean.orderTypeValueChangeListener}">                    
                          <f:selectItems id="si2" value="#{lovManagedBean.orderTypeItems}"/>
    </af:selectOneChoice>
    <!-- DROP DOWN 2 -->
    <af:selectOneChoice label="Request Type" id="soc1" required="true"
                                            validator="#{lovManagedBean.requestTypeValidator}"
                                            binding="#{userAuthentication.requestType}">
                                          
                                           
                          <f:selectItems id="si1" value="#{lovManagedBean.requestTypeItems}" />
    </af:selectOneChoice>
    Managed Bean code
      public List<SelectItem> getRequestTypeItems() {
        List<SelectItem> list = new ArrayList<SelectItem>();
    
        list.add(new SelectItem("XXX","XXX"));
        list.add(new SelectItem("YYY","YYY"));
       
       
        this.requestTypeItems = list;
         return list;
      }
    
      public void orderTypeValueChangeListener(ValueChangeEvent event ) {
          System.out.println("+++ Calling LOVManagedBean.orderTypeValueChangeListener()");
          System.out.println("Old Value for order type:" + event.getOldValue() );
          System.out.println("New Value for order type:" + event.getNewValue());
          if(event.getNewValue().equals("Time and Expense")){
            //Code to add LOV in drop down
          }
              
        
      }

    You could make it according to the following example:

    Sample.JSPX:



    xmlns:f = "http://java.sun.com/jsf/core".
    xmlns:h = "http://java.sun.com/jsf/html".
    xmlns:af = "http://xmlns.oracle.com/adf/faces/rich" >




    *
    autoSubmit = 'true' immediate = "true".
    * valueChangeListener = "#{pageFlowScope.SampleBean.onValueChangeListener}" > *.
    **
    **
    **
    *
    * partialTriggers = "soc1."
    * Binding = "#{pageFlowScope.SampleBean.selectOneChoice2}" > *.
    *
    * id = "si3" / > *.
    **



    * SampleBean.Java: *.

    import java.util.ArrayList;
    import java.util.List;

    Import javax.faces.event.ValueChangeEvent;
    Import javax.faces.model.SelectItem;

    Import oracle.adf.view.rich.component.rich.input.RichSelectOneChoice;

    public class SampleBean {}
    Private RichSelectOneChoice selectOneChoice2;

    public SampleBean() {}
    DataSource.Add (new SelectItem ("XXX", "XXX"));
    DataSource.Add (new SelectItem ("YYY", "YYY"));
    System.out.println ("to the constructor");
    }

    Private list datasource = new ArrayList ();
    private SelectItem newSelectItem = new SelectItem ("ZZZ", "ZZZ");

    * public Sub onValueChangeListener (ValueChangeEvent valueChangeEvent) {*}
    * if (valueChangeEvent.getNewValue () .equals ("Add") == true) {*}
    * System.out.println("::: Adding new select item choice"); *
    * datasource.add (newSelectItem); *
    *} else {*}
    * if (valueChangeEvent.getNewValue () .equals ("JustSelect") == true) {*}
    * System.out.println("::: Removing the added select item choice"); *
    * datasource.remove (newSelectItem); *
    * System.out.println (datasource.size ()); *
    *}*
    *}*
    * this.selectOneChoice2.setValue (datasource); *
    *}*

    public void setDatasource (the list data source ) {}
    This.DataSource = data source;
    }

    public getDatasource() {list
    Returns the data source;
    }

    public void setSelectOneChoice2 (RichSelectOneChoice selectOneChoice2) {}
    this.selectOneChoice2 = selectOneChoice2;
    }

    public RichSelectOneChoice getSelectOneChoice2() {}
    Return selectOneChoice2;
    }
    }

    * Ensure that the bean is saved in pageFlowScope.*

    Thank you
    Nini

  • How to determine the Thread of execution for PostUIMessage,

    Greetings:

    I'm trying to develop an application TestStand with two Interfaces (in addition to the sequence editor) user, and I need to be able to view messages from interface user back and forth between two user interfaces.

    So far I managed to create a user interface, and I can post messages for the user interface of a TestStand sequence to my user interface. large.  I spent the reference Application Manager in the constructor of the UI object.

    Now, I want a button on my first UI to cause a user interface message to send to my second UI... The PostUIMessage options I have are Engine.PostUIMessage or Thread.PostUIMessage... in both cases that I need the thread, I don't think I have unless I pass it explicitly in the constructor.  Ideally, I would like to pass only a single object in the constructor (to keep things simple).

    I tried to create versions of my first UI that pass the engine reference, or reference to the SequenceContext, but I seem to be impossible to extract the info that I need these.  For example, the SeqContext, in theory I can get the engine and the Thread, but when I try to get the reference of the AppMgr of engine

    TsEngine = seqContext.Engine;
    AppMgr = TsEngine.GetInternalOption (InternalOptions.InternalOption_ApplicationManager) (ApplicationMgrClass);

    I get the following exception:

    The instance of the .NET class could not be found.

    Impossible to object cast COM type 'System.__ComObject' to the class type 'NationalInstruments.TestStand.Interop.UI.ApplicationMgrClass '. COM components that enter the CLR and do not support IProvideClassInfo or who have not any registered assembly are wound in the __ComObject type. Instances of this type cannot be cast to any other class; However they can be cast to interfaces as long as the underlying COM component supports calls QueryInterface for the IID of the interface.
    Source: SidecarLib to

    What I really need to move the app Manager frame of reference and sequence and the thread as separate arguments my constructor, or I missed something that causes the exception above?

    Thank you very much

    Tom MacLean

    It seems I've found the problem.

    The code sample that I created on my user interface is from the article "launch of a floating .NET form in TestStand.  In this example, the reference of the Application Manager is in a member of the class defined as:

    Class AppMgr ApplicationMgr;

    If you try to get the referral of Application of the motor as this handler:

    AppMgr = seqContext.Engine.GetInternalOption (InternalOptions.InternalOption_ApplicationManager) (ApplicationMgrClass);

    It is then the exception mentioned above is generated.   If, however, the reference to Application Manager is defined as:

    ApplicationMgr AppMgr.

    and it is extracted in the context of the sequence as follows:

    AppMgr = seqContext.Engine.GetInternalOption (InternalOptions.InternalOption_ApplicationManager) (ApplicationMgr);

    everything works as I had planned (without exception).

    I hope that it can save someone else some grief.

    See you soon,.

    Tom MacLean

  • Question of the ADF during execution of the established steps FDMEE

    Hello

    Whenever I try to run any step in the data loading Workbench in FDMEE 11.1.2.3 (PSU520) I immediately get the following error message:

    "FDMEE + ADF_FACES-60097: for more information, see the error log of the server for an entry beginning with: 60096-ADF_FACES: server during the PPR, #5 Exception.

    If I run the same underlying data loading rule of the DLR page it works ok.

    Is this a bug of the ADF? Any other ideas?

    Kind regards

    Simon

    Simon,

    Check also that the period all mappings are set correctly for the POV you are dealing with.

    Concerning

  • Loading in the library during execution?

    I built an animation flash (for a website) which requires a number of good quality JPG images.  I don't display any of this at first, so I don't want to wait for them all to load before starting the animation.  So, I want to be able to load these images in the background - the obvious process would be MovieClipLoader.loadClip () method.  It works fine if I load it into an INSTANCE of a moveclip (either existing on the stage or one that I have creat in actionscript) - but I really want to load into a clip from the library.

    The problem is that I find myself using these images in two different movies on the scene: everyone gets a movieclip in the library (which contains the image I want).  So my original thought was simply to load (with the help of loadClip()) in the film of the library - which in turn arise under the movieclips of two floors with this clip of library in the panel mounting.  However, I can't get loadClip() to use a library object.

    I tried to export the library movieclip for actionscript (giving it a name) - but loadClip() doesn't seem to load in it.  I can't get loadClip() to load it into an instance that exist on the stage.

    Sorry if I ask a stupid question - I do not a lot of flash programming - even though I have a great experience of programming in other languages.

    So is this possible?  Is there another way to accomplish what I want to do?

    I can easily load it into an instance of movieclip - but I do not want to load each image twice (in two different clips that I need to handle)-where my desire to load into an object of single library that end up having multiple instances on the stage.

    My other thought was to load into an instance and then COPY this instance to the second instance.  But I can't seem to find a way to copy an element in another clip?

    Pointers would be much appreciated.

    Just to clarify, here is an example.

    * I have several clips library (call them clip1, clip2, clip3...)  that contain a single image with a JPG image in this context.

    * I have a movieclip called bkgnd library that has 10 images inside.  Each image has an instance of the various clips above (e.g. Framework 1 has inside clip1, framework 2A clip2, frame 3A clip3 inside etc).  At runtime, this movement is handled through gotoAndStop() to display a particular image.

    * I use this movieclip library bkgnd at TWO locations on the real scene (two cases).  Each is controlled via actionscript to display individual frames (images in particular) via the gotoAndStop() method.

    * I want to be able to load the individual images during run - my thought was to use loadClip() to load JPG files clip1, clip2, clip3... clips in the library.  However, loadClip() does not seem to load in a clip from the library.

    You cannot load in the library or in a clip from the library.  objects in your fla library do not exist in your swf file unless they are instantiated.

    You can load two times (and, if you wait until the loading is finished with the first load, the 2nd will be retrieved from the cache of the user and not downloaded) or you can use the bitmapdata's draw() method class' to copy the first loaded image and reproduce them.

  • Changing the properties of the element during execution

    Is it possible to change the properties of the element when running on APEX. I'm looking for the equivalent to SET_ITEM_PROPERTY command in Oracle Forms.

    Yes, I want to

    It's the $x('P1_ITEM').size = number_of_chars_you_want

    P.S. Check this site: http://www.w3schools.com/HTMLDOM/
    It contains most of the properties of the DOM element.

    Hope that answers your question,
    Rutger

  • Turn off the screen during execution of operating system

    Hello
    Is there a way to disable the display of a Toshiba L300 19 f while the system works (plays music for example)...?

    Thank you.

    Of course you can do it.

    I do not know what power profile that you use, but if you use the balanced power plan type parameters and sets Turn off the option to display for 1 minute.
    I do the same when the laptop is running and when I want to listen to my favorite online radio station. I put it at 1 minute.

  • Zoom in or on the graph during execution of VI

    Hi all

    Currently I have a Subvi popup that contains multiple locations of data collection for the user to view.  When the user clicks on the 'Stop' button on the Subvi, this sub - VI will close.  So I section tracing the program in a while loop.  I believe that this is the reason why I wasn't able to use the graphics palette to make a zoom in and zoom out right?  Should I just leave it track section out of the while loop then?

    Thank you

    Lynniz

    Place the property within a structure of case node and turn it back on once the iteration Terminal is "1". (not zero!)

    And please put a small wait inside the loop, there is no reason that he should turn that fast. (Given that the data never change in your example, the earrings inside and around graphic terminal belong outside of the big loop.) However, I guess that your real application differs )

    NOTE: you could also use the antiderivative "of first broadcast?" or allow it when [i] = 0, but in this case, you would need a small sequence structure in order to ensure that this happens after ther graphic terminal is written for the first time.

    Also note that the xy graphs take complex data, simplifying the wiring and data structures.

Maybe you are looking for

  • Library - click on a bookmark and it will open in a new tab?

    Using FF 28.0 I have the opening of the library and click on a bookmark in "Unsorted Bookmarks." . . . It will open in the tab in the browser that I currently opened, such as my email address . . . Is it possible to open the bookmark in a new tab?

  • Re: Cannot create flash drives recovery media

    I recently bought a new Toshiba NB305-N440BL and updated netboo to upgrade to Windows 7 Home Edition Premium. The Wizard "Create the recovery media", as suggested, I tried to create the recovery on two flash drives media. Flash memory were new and ha

  • HP stream 11-d001dx / 11-d010n: Bios boot password

    Please help I need a BIOS boot passwordRecovery for my computer codeStream HP model number11 - d001dx or d010nr-11, I get this messageSystem disabled54852504

  • Lower the wei aero with the best material

    I had a processor core i3 350 m with built-in graphcis and had a score of wei aero of 4.6 and 5.2 game. I got the updated version of this laptop with the same exact features but with a processor core i5 460 m and the score fell to 4.4 and 5.3 games 2

  • Configure the message that I don't understand

    My son has an Acer laptop with Windows Vista as the operating system.  We do not know why, but now when it turns on the machine, a screen lights up with the message - configuring updates: stage 3 of 3-0% complete.  After a few seconds of this, the sc