Hi Roger, Thanks so much for all the advice and direction. I'll get back to you if I have any more questions
On Fri, Jul 19, 2013 at 10:48 PM, Roger L. Whitcomb < roger.whitc...@actian.com> wrote: > Hi Ajay, > Well, your background is very interesting and encouraging, so > thank you for your desire to contribute! > So, let me see if I can explain a bit more. There definitely > does have to be a "repaint" call somewhere in the Pivot or application > code, because (obviously) nothing will get drawn without it. In the > Pivot environment the "skin" classes are responsible for both > keyboard/mouse interaction and for painting onto the Java Graphics2D > canvas. The interaction between the component classes and the skin > classes is mostly done via "listeners", which are called to notify any > interested code of changes that need to be processed. So, whenever the > underlying component data (such as the text of a Label) is changed, the > appropriate listener is called (which, at least, will be the skin of > that component), which then will invalidate the region, redo the > component's layout, and then (eventually) repaint the new text. So, all > of that takes place in response to your application simply doing a > "label.setText(...)", without any more intervention from the > application. > The code you are seeing in the Vocabulary plugin looks like it > is part of a custom container component, which is responsible for > forcing appropriate repaints of its children. But, from what you've > told me so far of what you are doing I don't think you'll need any code > like that in your application, since the appropriate "invalidate" and > "repaint" calls will all happen pretty much automatically when you > change the underlying data in the Pivot components. > BTW, I like your proposal, and I think Pivot will serve very > well to build this application for Lucene. I have actually been wanting > other Apache projects to look to Pivot to build GUIs they might need, so > this is a perfect example of what I've been hoping for! > As for suggestions on implementing features: > 1) The menu bar is available inside a Frame as a MenuBar (see the > http://pivot.apache.org/tutorials/menu-bars.html tutorial) > 2) Tabbed documents are available using the TabPane class (tutorial > here: http://pivot.apache.org/tutorials/tab-panes.html) > 3) The numeric spinner ("Number of top terms:) is available. > 4) The "Available fields" list can be done with a TableView > (http://pivot.apache.org/tutorials/table-views.html). > 5) The Analyzer tool's text field can likely be a TextArea if all you > need to do is highlight a single piece of text, or a TextPane if you > need to do more complex coloring, bolding, multiple highlights, etc. > (tutorial here: http://pivot.apache.org/tutorials/text-areas.html for > TextArea and there is a TextPane demo in the source code here: > http://svn.apache.org/repos/asf/pivot/branches/2.0.x/demos/src/org/apach > e/pivot/demos/text/ ). > 6) The token list in the Analyzer could be a ListView (see tutorial > here: http://pivot.apache.org/tutorials/lists.html). > 7) The only component you will likely have to do some special work with > is the top one where the left-hand column has highlighted and bold item > descriptions, and the right-hand column has the associated values. > Although you can probably do it relatively easily with a TableView and a > custom renderer for the first column (see an example here: > http://pivot.apache.org/tutorials/table-views.custom.html). > > If you can download the Pivot source, I would build either the > current "branches/2.0.x" code, which is very stable and should be > released soon, or "trunk", which is pretty much the same except for some > new stuff I'm working on to do remote file browsing. The current > release code (2.0.2) is okay too, but there are some improvements for > version 2.0.3 that could be helpful. > > Please continue to feel free to ask for help here. As I said, > this is something dear to my heart, so I will help as much as I can. > Also, if there are things you feel could be improved in Pivot, you can > definitely suggest those too. The goal of the project is to be useful > in creating GUIs just as you are doing. > > Thanks, > ~Roger Whitcomb > > > -----Original Message----- > From: Ajay Bhat [mailto:a.ajay.b...@gmail.com] > Sent: Friday, July 19, 2013 6:22 AM > To: dev@pivot.apache.org > Subject: Re: How to highlight text using Pivot? > > Hi Roger, > > On Fri, Jul 19, 2013 at 12:02 AM, Roger L. Whitcomb < > roger.whitc...@actian.com> wrote: > > > Well, to change the text on a Label, you just have to call > "label.setText(...);". The "business logic" in your first button just > has to keep track of how many times it has been pushed (i.e., which > saying you want to display next), and set the correct text each time. > > > > Okay, got it. > > > > > I'm not sure exactly what you're trying to do with the second > button.... > Do you just want it to make the label show up? In order to do that, > just > do: > > BoxPane boxPane = .... // Or could be set using a @BXML > annotation > > Label label = new Label("initial saying"); > > boxPane.add(label); > > > > The repaint should be taken care of automatically by the skin(s). > > > > Alternatively, you could always have the Label be included in the > BoxPane, but just set it initially invisible ("visible='false'" in the > .bxml file), and then in response to your second button press, call > "label.setVisible(true);". > > > > Am I correct in thinking that's what you want to accomplish? > > > > HTH, > > ~Roger > > > > I'm having a bit of trouble myself understanding the repaint() in my > context and whether I need it or not. > > *Some background info:* I had attended the ASF ICFOSS Pilot programme in > India [1] conducted by Luciano Resende [2] and as part of the program > we're encouraged to contribute to the Apache community. > > I decided to do a project in Lucene[3]. The goal is to port some GUI > features into the Luke application in the sandbox of Lucene [3] using > Pivot, since Luke currently uses Thinlet (an LGPL licensed) API. [5] > > I studied some Pivot, did a proposal and used one of your earlier > suggestions in the proposal. > > The proposal is here : > https://docs.google.com/document/d/18Vu5YB6C7WLDxnG01BnZXFEKUC3EQYb0Y5_t > CJFb_sc/ > > Coming back to the problem : > I'm seeing repaint() being used in the Vocabulary plugin (see Page 5 of > above doc) > > The repaint() method as in src of Luke is : > private void repaint(Object component, Object classname, Object part) { > Rectangle b = getRectangle(component, "bounds"); > if (classname == "combobox") { // combobox down arrow > repaint(component, b.x + b.width - block, b.y, block, > b.height); // icon?+ > } else if ((classname == "tabbedpane") || // tab > (classname == "menubar") || (classname == ":popup")) { > // menuitem > Rectangle r = getRectangle(part, "bounds"); > repaint(component, b.x + r.x, b.y + r.y, (classname == > ":popup") ? b.width : r.width, r.height); > } > /*Some more similar if statements*/ > } > > It creates a rectangle object (from java Container class, IIRC) and sets > bounds by calling this function. > > private void repaint(Object component, int x, int y, int width, int > height) { > while ((component = getParent(component)) != null) { > Rectangle bounds = getRectangle(component, "bounds"); > if (bounds != null) { > x += bounds.x; > y += bounds.y; > } > Rectangle view = getRectangle(component, ":view"); > if (view != null) { > Rectangle port = getRectangle(component, ":port"); > x += -view.x + port.x; > y += -view.y + port.y; //+ clip :port > } > } > repaint(x, y, width, height); > } > > I'm not seeing the point of creating bounds here. So I'm not sure why we > need to repaint any item in Pivot or if we need to repaint at all. Maybe > you could shed some light on this? > > Please go over my proposal and feel free to make any comments for how I > could do the features. > > [1] http://community.apache.org/mentoringprogramme-icfoss-pilot.html > > [2] http://people.apache.org/~lresende > > [3] https://issues.apache.org/jira/browse/LUCENE-2562 > > [4] https://svn.apache.org/repos/asf/lucene/sandbox/luke > > [5] http://luke.googlecode.com/svn/trunk/ > > -- > Thanks and regards, > Ajay Bhat > -- Thanks and regards, Ajay Bhat