Monday, 15 August 2011

java - How to implement a JPanel that shows/hide content depending on its width? -


I am trying to apply a JPanel which displays more or less information based on available size.

In fact, the idea is such a default content:

image Enter details here

This can be reduced when the space is reduced:

 Image Description Here

My code is such as:

  import net.miginfocom.swing.MigLayout; Import javax.swing *; Class Panel Dimos JPanel {Private Final JLabel Title = New JLab (); Private Final JLab Counter 1 = New JLABEL ("00"); Private Final JLAB counter 1 label = new JLab (); Private Final JLab Counter 2 = New JLABEL ("00"); Private Final JLab counter 2 label = new JLab (); / ** * An new ABS App Cadre message blocks the panel panel * / Public panelmedom () {this.SsetOpaque (wrong); InitGUI (); } Private Final Zero initGUI () {// 1Â °) Final Miglaut migLayout = New MigLayout ("fillx, hidemode 2, debug", "[growprio 0] []" // defined 4 columns); SetLayout (migLayout); // 2 °) // add (title, "spanx"); Plus (counter 1, "newline"); Add (counter1Label); (Counter2); Add (counter2Label); } Public static zero main (string [] Args) {Final JFrame jFrame = New JFrame ("test 4"); JFrame.getContentPane (). SetLayout (new megallout ("Phillix, debug")); Final panel dimo item 1 = new panel demo (); Item1.title.setText ("Element 1"); Item1.counter1Label.setText ("First LBL"); Item1.counter2Label.setText ("Second LBL"); JFrame.getContentPane (). Add (item 1, "groupex, gpx 110"); Final panelDimo item 2 = new paneldomain (); Item2.title.setText ("Element 2"); Item2.counter1Label.setText ("First LBL"); Item2.counter2Label.setText ("Second LBL"); JFrame.getContentPane (). Add (item 2, "groupux, gpx100"); JFrame.pack (); JFrame.setVisible (true); }}   

I tried to hide / hide my secondary labels, but I was not successful, tried to add a component listener and override component risized ().

Is anyone aware of implementing such behavior that increases preferences of well-being with Migelout increases?

Update1: I was wondering ... what if I set the minimum 1 + 1 label counter, and the maximum size for counter 2 + label 2 and then the operations Will the mechanization work to change the shape and change the size of the minimum or its maximum?

How about:

  public static JPNL panel (string ) {Jepynel Panel = New Zygel (New Miglite ("Inset 0, Rap 4, Philix, Debug", "[] [] 200 Shrink) [200 Decrease, Increase 200]"); Panel.add (new jlabel (name), "span x 4"); Panel.add (new JLab ("00")); Panel.ed (new jlabel ("first lbl"); Panel.add (new jlab ("01"); Panel.add (new JLABEL ("second LLBL")); Return panel; } Public static zero main (string [] algs) {Jepynel panel = new zipeline (new mangleout ("Inset 10, gap 10, Philix, debug")); Panel.add (panel ("element 1"), "w (50% - 15)!"); Panel.add (panel ("Element 2"), "w (50% - 15)!"); Jeffre Frame = New Gefram (); Frame.setContentPane (panel); Frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); Frame.pack (); Frame.setVisible (true); }   

I had difficulty in shaping the two main columns equally; I had to do by setting the width on the components instead of columns. I'm not sure why this is so.

r - fit an xtable to a pdf file -


I am creating a sweat document that uses the extensible to make the test and puts it in the PDF file. It works but the table document is not suitable and some text is missing. Is there a way to align the text in a PDF file? / P>

This is my data:

  dput (x) structure (list = structure (c (3l, 2l, 1l), label = c ("apersver" , "Db", "web"), class = "factor"), group = structure (c (2l, 1l, 1l) owner = structure (c (1l, 1l, 1l), label. = "Infrastructure", class = "factor"), server = structure (1: 3, .ll = c ("servera", "serverb", "serverc"), class = "factor"), numberconp = c (64 L, 120 L, 120 L), Description = Structure (C (1 L, 3L, 2L), .Label = C ("Front end server for server web traffic", "They B "to create dynamic content", "Customer data and login information"), class = "factor"), cost = structure ("AP", "group", "owner", "server", " Server "," number "," number "," description "," cost "), (" $ 200,000 "," $ 400,000 "," $ 500,000 ", class =" factor "))) , Class = "data.frame", line.Name = c (na, -3l))   

This code is to insert the table into PDF: print (ext. (X, caption = paste ("summary of application"), table. Placement = "! H", caption.placement = "top", align = c ('l', 'p {1.5in}', representative ('c', 6)))

I recommend checking out, many examples are useful, in fact, if you reduce the wire If you do not want to adjust your table, I get two options:

  1. Use small fonts.
  2. Use landscape mode.

    Here, I use a combination of both:

      \ documentclass {article} \ usepackage {rotating} \ begin {document} & lt ; & Lt; Data, echo = FALSE & gt; & Gt; = Library (ext.) X & lt; - Structure (list (app = structure (C (3L, 2L, 1L), .lLL = C ("apserver", "db", "web"), class label = structure (c (2l, 1 L, 1L), .Lale = C ("back", "front"), class = "factor"), owner = structure (C (1L, 1L, 1) LLL = C ("server A" "Serverbie", "serverc", class = "factor"), LLL = "infrastructure", class = "factor"), server = structure (1: 3, number cpu = c (64l, 120l, 120l ), Description = Structure (C (1L, 3L, 2L), .Lll = C ("Front and Head for Server Web Traffic" "," Web Templates To Generate Dynamic Content "," Cost = Structure "(1: 3, .LL = C (" $ 200,000 "," $ 400,000 "," $ 500,000 ", Consumer Data and Login Information Name = c ("app", "group", "owner", "server", "number cpu", "description", "cost"), class = "data.frame", line = name = c , -3 L)) @  gt; = print (ext. (X, caption = paste ("summary of applications"), caption Placement = "top", align = c ('l', 'p {1.5in}', representative ('c', 6)), size = "footnotesize" Floating.environment = "sidewaystable") @ \ & {document}   

    Note that you have to use latex package rotation this should give you something like this :

    Output

python - Best practices for Querying graphs by edge and node attributes in NetworkX -


Use Network X for new social network analysis queries, and new in the library. By query, I mean choose / create subclients based on the properties of the nodes of both sides, where the edges are made, the nodes have attributes, the graph is using a multidi graph of the form

  G2 = nx.multiDiGraph () G2.add_node ("UserA", {"type": "Cat"}) G2.add_node ("UserB G2.add_node (" UserC ", {" type ":" mouse G2.add_node ("Like", {"type": "feeling"}) G2.G2.add_edge ("UserA", 'Hates', statementit = "1") G2.add_edge ("Hates" , 'UserB', Statement = "1" ("Hate", {"Type": "Experience"}) G2.add_edge G2.add_edge ("UserC", 'Hates', statementit = "2") G2.add_edge ("Hate", 'UserA', Statement = "2") G2.add_edge ("UserB", 'hate' G2.add_edge G2.add_edge ("Hate", "User", Statement = "3 G2.add_edge ("User C", 'Like', Statement = "3") G2.add_edge ("Like", "User B", Statement = "3")   

Inquiries with nodes for

 , data in G2.nodes_iter (data = true): if (data ['type'] == "cat"): # All edges from these nodes Removing # Then using a filter for a specific statement_id # or all with a specific statement ID Receive the edges # Find from node et "cat" reboot   

Is there a better way of query? Or is it best practice to create custom iterations to make a subfraph?

Alternatively (and a different question), the graph can be simplified, but I am not using the graph below because the object of type "Hate" will be with predecessors whether it is easy to ask ? G3 = NX G3.add_node ("UserA", {"Type": "Cat"}) G3.add_node ("UserB", {G3.add_gege ("UserA", "UserB", "UserB", "User", "User", "UserA", "UserA", "UserB", Statement = "1", label = "Hates"}), label = "Hates")

Other notes:

haskell - Returning True for only 1 Function out of the list of 3 -


Since I'm sure to use global variables in Haskell, I'm thinking that anyway I get the following Can i

  - There are elements in the list that are the odd list HasOdd :: [integer] - & gt; Bool - There are elements in the list that are even in the list of HASEven :: [integer] - & gt; Boole - The list has a length & gt; 5 long list :: [integer] - & gt; Boole - Function in Map [Bool] - This function can not be modified to fix the problem. Checklist :: [integer] - & gt; [Bool] checkList xs = map (\ y - & gt; y xs) listChecker where listChecker = [listHasOdd, listHasEven, longList]   

Anyway, I can make sure that in them Only a true return from?

For example, [1,2,3,5], I just want to return to the list which is true [true, false, false] (evaluation from top to bottom ).

Another example, [2,4,6,8,10,12,14], should be returned [false, true, false]

In other words, the checklist [1,2,3,5] returns [true, false, false], checklist [2,4,6,8,10,12,14] returns [false , True, false]

** The last task will always be wrong in my example, because it is not inaccessible

I know that I have an if statement I can do that to check that the last one is true but it seems like a very dumb idea. Or is this really the way to do it? (Recalling the results of "previous ceremony" while keeping Haskell in mind)

This is the best I can come together in It is relatively painless to handle the number of potential pockets of a poker hand, for example.

  Data Results = ListHasOdd | List HASEven | Longlist | Non-Eddy Result Forum List :: [Integer] - & gt; Result resultFelllist XS | Any strange xs = ListHasOdd | Any xs = ListHasEven | 5 & ​​lt; Length x = long list | Otherwise = noop list HasOdd = (ListHasOdd ==). Results lightlist listSeven = (List HASEven ==). The result is a long list = list (Longlist ==) but it is also stupid: instead of creating a  [bool] , why not use only the  result ?  

Edit: or we can pay attention to what mean

 < Code> listHasOdd xs = a strange Xs listHasEven [] = incorrect listingHess xs = all also xs - if they are not all, then at least one should be strange, and `true 'will give' true 'long _ = false - If there are at least 5 elements in the list - then there is at least one strange element in the list - (and 'list' will be 'true') - or there are also at least five elements in the list - (and 'catalog' TRUE`)    

java - Generate API docs with Javadoc -


I am writing Javadox for a project, on which I am working, and @link each endpoint is linked to linking to Javadock for each method.

Ideally, I want to do something like this:

  POST / API / resource call {@link resource # getAll () resource @ getAll} received / api / Resources / {id} call {@link resource # getById (int) resource # getById}   

I am open to any solutions that are similar.

There is a feature in Maven that gives you the HTML markup to src / main / javadoc / overview. Html and it will process all the tags and write the output on the main Javadoc page.

This works very well when you use MarketDown Overview.html Page

jQuery $(window).resize not firing within jQuery plugin -


I have created a custom jQuery plugin and having problems getting a window-sized function to fire inside the plugin I was broken down to do the basics of obtaining it, I did not know why he was not firing:

 ; (Function ($, window, document, undefined) {$ .fn.test = function (option) {$ (window). Reset (function () {warning ('sdsd');})}}}}}) JQuery); $ (Function () {$ ('. Element'). Test ();});    

In your case the window is undefined because you can not Passing it in the function.

 ; (Function ($, window, document, undefined) {$ .fn.test = function (options) {$ (window). Resize (function () {warning ('sdsd');});};}) , Window, document); // & lt; --- Make changes here    

sharepoint - Xstl global variable set in for each and used after foreach -


First of all, I am new to XSLT. I am working with the Sharepoint list and receive a link to show me There is a need to do if data exists in specific quarters. If there is no data in a certain quarter, then I should have a label that says so.

So what have I done that I created a foreach loop for every data of the same month of a given year. I know that I can not open a variable in XSLT, but I do not know how to do it I need it. Here is a sample of my code as I am working with SharePoint, so I do not have access to XML. I: /

    & lt; xsl: variable name = Select "DataQ3" = "'Incorrect" /> & Lt; Select xsl: variable name = "DataQ4" = "'false'" /> & Lt; Xsl: each selection = "../ line [Generate-ID () = Generate-ID (key ('month', subdiver (date @ 6, 7)) [substring ('@ date', 1, 4) = $ VarYear)] [1])] "& gt; & Lt; Select xsl: variable name = "currentMonth" = "number (substring (date @ 6,7)" /> & Lt; XSL: Select & gt; & Lt; Xsl: when testing = "$ current mont & gt; = 1 and $ current churn $ lt; = 4" & gt; & Lt ;! - Set $ ​​DataQ1 right - & gt; & Lt; / XSL: When & gt; & Lt; Xsl: When testing = "$ current churn> = 4 and $ current churn $ lt; = 7" & gt; & Lt ;! - Set $ ​​DataQ2 correct - & gt; & Lt; / XSL: When & gt; & Lt; Xsl: when test = "$ current churning = 7 and $ current churn $ lt; = 10" & gt; & Lt ;! - Set $ ​​DataQ3 correct - & gt; & Lt; / XSL: When & gt; & Lt; XSL: otherwise & gt; & Lt ;! - Set $ ​​DataQ4 correct - & gt; & Lt; / XSL: otherwise & gt; & Lt; / XSL: Select & gt; & Lt; / XSL: for-each & gt; & Lt; Div & gt; & Lt; XSL: Select & gt; & Lt; Xsl: when test = "$ DataQ1 = 'true'" & gt; & Lt; A & gt; & Lt; Xsl: attribute name = "href" & gt; & Lt; Xsl: Select the value = "www.example.come" /> & Lt; / XSL: Specialty & gt; & Lt; Xsl: Select Value = "'Linked DotDefault Q1'" /> & Lt; / A & gt; & Lt; / XSL: When & gt; & Lt; XSL: otherwise & gt; & Lt; Xsl: Select the value = "'There is no data for this quarter.'" /> & Lt; / XSL: otherwise & gt; & Lt; / XSL: Select & gt; & Lt; / Div & gt;    

You use the key function in your code You did not post the announcement of your key but I think you can get it from the following code:

  & lt; Div & gt; & Lt; XSL: Select & gt; & Lt; Xsl: When test = "../ line [substrings (date, 1, 4) = $ varYear and substrings (date, 6, 2) & amp; gt; = 1 more substring (date, 6, 2) & Amp; 4; "& gt; & Lt; A href = "http://www.example.com/" & gt; Linkotodonta Q1 & lt; / A & gt; & Lt; / XSL: When & gt; & Lt; Xsl: otherwise & gt; There is no data for this quarter. & Lt; / Xsl: otherwise & gt; & Lt; / XSL: Select & gt; & Lt; / Div & gt;   

Some other notes:

  • In your testing for Q1, you entered $ currentMonth & lt; = 4 is written. I think what you want $ currentMonth & lt; 4 . substring (@Date, 6, 7) has been used to remove @ date from the month
  • . The third argument for substrings is the length of the sub-row, not the end index. You might want to suborg (date, 6, 2) .
  • and , you can just type string .