Search Results

Search found 4489 results on 180 pages for 'black cobra'.

Page 168/180 | < Previous Page | 164 165 166 167 168 169 170 171 172 173 174 175  | Next Page >

  • JProgressBar.stringPainted(true); is not working

    - by Mirza Ghalib
    This is a part of my java code, in this code I have written that when I click the button the value of JProgressBar should becomes 0 and stringPainted(); becomes true, but "string painted" is not visible when I click the button, please help. import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JProgressBar; public class R implements ActionListener { static int y; CustomProgressBar b = new CustomProgressBar(); public static void main(String arg[]) throws Exception { new R(); } public R() throws Exception { JFrame f = new JFrame(); JButton btn = new JButton("Click"); f.setExtendedState(JFrame.MAXIMIZED_BOTH); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setUndecorated(true); f.setLayout(new FlowLayout()); btn.addActionListener(this); f.add(b); f.add(btn); f.setVisible(true); } class CustomProgressBar extends JProgressBar{ private static final long serialVersionUID = 1L; private boolean isStringToBePainted = false; public CustomProgressBar() { super(JProgressBar.VERTICAL,0,100); } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); if(isStringToBePainted ) { Dimension size = CustomProgressBar.this.getSize(); if( CustomProgressBar.this.getPercentComplete()<0.9 ) R.y = (int)( size.height - size.height * CustomProgressBar.this.getPercentComplete() ); String text = getString(); g.setColor(Color.BLACK ); g.drawString(text, 0, R.y); } } @Override public void setStringPainted(boolean b) { isStringToBePainted=b; } } @Override public void actionPerformed(ActionEvent e) { b.setValue(0); b.setStringPainted(true); } }

    Read the article

  • I have problems with adding rows to data-binded DataGridView in desktop app.

    - by Mishko
    DataTable table1 = new DataTable(); double brutoUkupno1 = 0; double porezUkupno1 = 0; double doprinosUkupno1 = 0; double netoUkupno1 = 0; double doprinosTeretUkupno1 = 0; double topliObrokUkupno1 = 0; double regresUkupno1 = 0; Connection con = new Connection(); table1 = con.boundTable(month, Convert.ToInt32(year)); //This is method which returns DataTable table1.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, null, null, null); table1.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, null, null, null); dgv2.Visible = true; dgv2.DataSource = table1; for (int i = 0; i < dgv2.RowCount - 2; i++) { topliObrokUkupno1 += Convert.ToDouble(dgv2.Rows[i].Cells[7].Value); regresUkupno1 += Convert.ToDouble(dgv2.Rows[i].Cells[8].Value); brutoUkupno1 += Convert.ToDouble(dgv2.Rows[i].Cells[9].Value); porezUkupno1 += Convert.ToDouble(dgv2.Rows[i].Cells[10].Value); doprinosUkupno1 += Convert.ToDouble(dgv2.Rows[i].Cells[11].Value); netoUkupno1 += Convert.ToDouble(dgv2.Rows[i].Cells[12].Value); doprinosTeretUkupno1 += Convert.ToDouble(dgv2.Rows[i].Cells[13].Value); //Now I am having problems with this below, putting things above to dgv2 : } dgv2.Rows[dgv2.Rows.Count - 1].Cells[0].Value = "Ukupno"; dgv2.Rows[dgv2.Rows.Count - 1].Cells[3].Value = month.ToString(); dgv2.Rows[dgv2.Rows.Count - 1].Cells[4].Value = year.ToString(); dgv2.Rows[dgv2.Rows.Count - 1].Cells[7].Value = topliObrokUkupno1.ToString(); dgv2.Rows[dgv2.Rows.Count - 1].Cells[8].Value = regresUkupno1.ToString(); dgv2.Rows[dgv2.Rows.Count - 1].Cells[9].Value = brutoUkupno1.ToString(); dgv2.Rows[dgv2.Rows.Count - 1].Cells[10].Value = porezUkupno1.ToString(); dgv2.Rows[dgv2.Rows.Count - 1].Cells[11].Value = doprinosUkupno1.ToString(); dgv2.Rows[dgv2.Rows.Count - 1].Cells[12].Value = netoUkupno1.ToString(); dgv2.Rows[dgv2.Rows.Count - 1].Cells[13].Value = doprinosTeretUkupno1.ToString(); dgv2.Rows[dgv2.RowCount - 2].Height = 3; dgv2.Rows[dgv2.RowCount - 2].DefaultCellStyle.BackColor = Color.Black;

    Read the article

  • color letters in a div

    - by Growler
    I've created a palindrome checker. I want to take it one step further and show the letters being compared as it is being checked. HTML: <p id="typing"></p> <input type="text" id="textBox" onkeyup="pal(this.value);" value="" /> <div id="response"></div> <hr> <div id="palindromeRun"></div> JS: To do this, I run the recursive check... Then if it is a palindrome, I run colorLetters(), which I'm trying to highlight in green each letter as it is being checked. Right now it is just rewriting palindromeRun's HTML with the first letter. I know this is because of the way I'm resetting its HTML. I don't know how to just grab the first and last letter, change only those letters' css, then increment i and j on the next setTimeout loop. var timeout2 = null; function pal (input) { var str = input.replace(/\s/g, ''); var str2 = str.replace(/\W/, ''); if (checkPal(str2, 0, str2.length-1)) { $("#textBox").css({"color" : "green"}); $("#response").html(input + " is a palindrome"); $("#palindromeRun").html(input); colorLetters(str2, 0, str2.length-1); } else { $("#textBox").css({"color" : "red"}); $("#response").html(input + " is not a palindrome"); } if (input.length <= 0) { $("#response").html(""); $("#textBox").css({"color" : "black"}); } } function checkPal (input, i, j) { if (input.length <= 1) { return false; } if (i === j || ((j-i) == 1 && input.charAt(i) === input.charAt(j))) { return true; } else { if (input.charAt(i).toLowerCase() === input.charAt(j).toLowerCase()) { return checkPal(input, ++i, --j); } else { return false; } } } function colorLetters(myinput, i, j) { if (timeout2 == null) { timeout2 = setTimeout(function () { console.log("called"); var firstLetter = $("#palindromeRun").html(myinput.charAt(i)) var secondLetter = $("#palindromeRun").html(myinput.charAt(j)) $(firstLetter).css({"color" : "red"}); $(secondLetter).css({"color" : "green"}); i++; j++; timeout2=null; }, 1000); } } Secondary: If possible, I'd just like to have it colors the letters as the user is typing... I realize this will require a setTimeout on each keyup, but also am not sure how to write this.

    Read the article

  • CSS Ease-in-out to full screen

    - by Aditya Singh
    I have a black background div of a size which contains an image. <div id="Banner"> <img onclick="expand();" src="hola.jpg"> </div> #Banner { position:relative; height:50px; width:50px; margin:0 auto; background-color:#000000; -webkit-transition: all 0.5s ease-in-out 0.5s; -moz-transition: all 0.5s ease-in-out 0.5s; -o-transition: all 0.5s ease-in-out 0.5s; transition: all 0.5s ease-in-out 0.5s; } <script type="text/javascript"> function expand(){ document.getElementById('Banner').style['height'] = '250'; document.getElementById('Banner').style['width'] = '250'; } </script> So when the user clicks on the image, the div transitions to 250, 250. My problem is that, i want it to to transition to full screen. The following javascript function does expand to fullscreen but the transition effect doesn't come. I need to do it from a javascript code without jquery. function expand(){ document.getElementById('Banner').style['position'] = 'absolute'; document.getElementById('Banner').style['height'] = '100%'; document.getElementById('Banner').style['width'] = '100%'; document.getElementById('Banner').style['top'] = '0'; document.getElementById('Banner').style['left'] = '0'; } Please advice. Update : Solution Roger below has provided with an alternative solution. This takes care if the document has already been scrolled and is another place. Will expand the div to full browser screen. sz=getSize(); //function returns screen width and height in pixels currentWidth=200; currentHeight=200; scalex=sz.W/currentWidth; scaley=sz.H/currentHeight; transx=0-((expandingDiv.offsetLeft+(currentWidth/2))-(sz.W/2))+document.body.scrollLeft; transy=0-((expandingDiv.offsetTop+(cuttentHeight/2))-(sz.H/2))+document.body.scrollTop; transx = transx.toString(); transy = transy.toString(); document.getElementById("Banner").style['-webkit-transform'] = 'translate('+transx+'px,'+transy+'px) scale('+scalex+','+scaley+')';

    Read the article

  • Split string in C every white space

    - by redsolja
    I want to write a program in C that displays each word of a whole sentence (taken as input) at a seperate line. This is what i have done so far: void manipulate(char *buffer); int get_words(char *buffer); int main(){ char buff[100]; printf("sizeof %d\nstrlen %d\n", sizeof(buff), strlen(buff)); // Debugging reasons bzero(buff, sizeof(buff)); printf("Give me the text:\n"); fgets(buff, sizeof(buff), stdin); manipulate(buff); return 0; } int get_words(char *buffer){ // Function that gets the word count, by counting the spaces. int count; int wordcount = 0; char ch; for (count = 0; count < strlen(buffer); count ++){ ch = buffer[count]; if((isblank(ch)) || (buffer[count] == '\0')){ // if the character is blank, or null byte add 1 to the wordcounter wordcount += 1; } } printf("%d\n\n", wordcount); return wordcount; } void manipulate(char *buffer){ int words = get_words(buffer); char *newbuff[words]; char *ptr; int count = 0; int count2 = 0; char ch = '\n'; ptr = buffer; bzero(newbuff, sizeof(newbuff)); for (count = 0; count < 100; count ++){ ch = buffer[count]; if (isblank(ch) || buffer[count] == '\0'){ buffer[count] = '\0'; if((newbuff[count2] = (char *)malloc(strlen(buffer))) == NULL) { printf("MALLOC ERROR!\n"); exit(-1); } strcpy(newbuff[count2], ptr); printf("\n%s\n",newbuff[count2]); ptr = &buffer[count + 1]; count2 ++; } } } Although the output is what i want, i have really many black spaces after the final word displayed, and the malloc() returns NULL so the MALLOC ERROR! is displayed in the end. I can understand that there is a mistake at my malloc() implementation but i do not know what it is. Is there another more elegant - generally better way to do it? Thanks in advance.

    Read the article

  • sub menu border calls onmouseout event

    - by insanepaul
    I've created a simple menu and submenu with tags(not allowed to use ul elements). To access the submenu the user hovers their mouse over the menu item. I use the onmouseover and onmouseout events to either show or hide the sub menu depending on which item is selected. A pipe (|) is used to seperate each submenu item and this is what is causing me problems. When a user hovers their mouse above the pipe character the subMenu div calls the onmouseout event which is not what I want. So I added padding around the pipe character and a minus margin so that there were no gaps between the pipe character and the other elements. This worked for all browsers including IE8. But in IE7 (I haven't tested IE6 yet) the submenu div calls the onmouseout event when I touch the top bit of either the left or right border of the pipe character span element. <div id="subMenu" onmouseout="hideSubMenu()" > <div id="opinionSubMenu" onmouseover="showOpinionSubMenu()"> <a id="Blogs" href="HTMLNew.htm">BLOGS</a> <span class="SubMenuDelimiter">|</span> <a id="Comments" href="HTMLNew.htm">COMMENTS</a> <span class="SubMenuDelimiter">|</span> <a id="Views" href="HTMLNew.htm">VIEWS</a> </div> <div id="learningSubMenu" onmouseover="showLearningSubMenu()"> <a id="Articles" href="HTMLNew.htm">ARTICLES</a> <span class="SubMenuDelimiter">|</span> <a id="CoursesCases" href="HTMLNew.htm">COURSES & CASES</a> <span class="SubMenuDelimiter">|</span> <a id="PracticeImpact" href="HTMLNew.htm">PRACTICE IMPACT</a> </div> </div> This is my css class #subMenu{ padding:10px 0px; background-color:#F58F2D; font-weight:normal; text-decoration:none; font-family:Lucida Sans Unicode; font-size:14px; float:left; width:100%; display:none;} #Blogs, #Comments, #Views, #Articles { padding:10px 5px; background:none repeat scroll 0 0 transparent; color:#000000; font-weight:normal; text-decoration:none; border:solid 1px black;} #Blogs:hover, #Comments:hover, #Views:hover, #Articles:hover{ color:#ffffff; text-decoration:none;} .SubMenuDelimiter{ padding:10px 5px; margin:10px -5px;}

    Read the article

  • Header Guard Issues - Getting Swallowed Alive

    - by gjnave
    I'm totally at wit's end: I can't figure out how my dependency issues. I've read countless posts and blogs and reworked my code so many times that I can't even remember what almost worked and what didnt. I continually get not only redefinition errors, but class not defined errors. I rework the header guards and remove some errors simply to find others. I somehow got everything down to one error but then even that got broke while trying to fix it. Would you please help me figure out the problem? card.cpp #include <iostream> #include <cctype> #include "card.h" using namespace std; // ====DECL====== Card::Card() { abilities = 0; flavorText = 0; keywords = 0; artifact = 0; classType = new char[strlen("Card") + 1]; classType = "Card"; } Card::~Card (){ delete name; delete abilities; delete flavorText; artifact = NULL; } // ------------ Card::Card(const Card & to_copy) { name = new char[strlen(to_copy.name) +1]; // creating dynamic array strcpy(to_copy.name, name); type = to_copy.type; color = to_copy.color; manaCost = to_copy.manaCost; abilities = new char[strlen(to_copy.abilities) +1]; strcpy(abilities, to_copy.abilities); flavorText = new char[strlen(to_copy.flavorText) +1]; strcpy(flavorText, to_copy.flavorText); keywords = new char[strlen(to_copy.keywords) +1]; strcpy(keywords, to_copy.keywords); inPlay = to_copy.inPlay; tapped = to_copy.tapped; enchanted = to_copy.enchanted; cursed = to_copy.cursed; if (to_copy.type != ARTIFACT) artifact = to_copy.artifact; } // ====DECL===== int Card::equipArtifact(Artifact* to_equip){ artifact = to_equip; } Artifact * Card::unequipArtifact(Card * unequip_from){ Artifact * to_remove = artifact; artifact = NULL; return to_remove; // put card in hand or in graveyard } int Card::enchant( Card * to_enchant){ to_enchant->enchanted = true; cout << "enchanted" << endl; } int Card::disenchant( Card * to_disenchant){ to_disenchant->enchanted = false; cout << "Enchantment Removed" << endl; } // ========DECL===== Spell::Spell() { currPower = basePower; currToughness = baseToughness; classType = new char[strlen("Spell") + 1]; classType = "Spell"; } Spell::~Spell(){} // --------------- Spell::Spell(const Spell & to_copy){ currPower = to_copy.currPower; basePower = to_copy.basePower; currToughness = to_copy.currToughness; baseToughness = to_copy.baseToughness; } // ========= int Spell::attack( Spell *& blocker ){ blocker->currToughness -= currPower; currToughness -= blocker->currToughness; } //========== int Spell::counter (Spell *& to_counter){ cout << to_counter->name << " was countered by " << name << endl; } // ============ int Spell::heal (Spell *& to_heal, int amountOfHealth){ to_heal->currToughness += amountOfHealth; } // ------- Creature::Creature(){ summoningSick = true; } // =====DECL====== Land::Land(){ color = NON; classType = new char[strlen("Land") + 1]; classType = "Land"; } // ------ int Land::generateMana(int mana){ // ... // } card.h #ifndef CARD_H #define CARD_H #include <cctype> #include <iostream> #include "conception.h" class Artifact; class Spell; class Card : public Conception { public: Card(); Card(const Card &); ~Card(); protected: char* name; enum CardType { INSTANT, CREATURE, LAND, ENCHANTMENT, ARTIFACT, PLANESWALKER}; enum CardColor { WHITE, BLUE, BLACK, RED, GREEN, NON }; CardType type; CardColor color; int manaCost; char* abilities; char* flavorText; char* keywords; bool inPlay; bool tapped; bool cursed; bool enchanted; Artifact* artifact; virtual int enchant( Card * ); virtual int disenchant (Card * ); virtual int equipArtifact( Artifact* ); virtual Artifact* unequipArtifact(Card * ); }; // ------------ class Spell: public Card { public: Spell(); ~Spell(); Spell(const Spell &); protected: virtual int heal( Spell *&, int ); virtual int attack( Spell *& ); virtual int counter( Spell*& ); int currToughness; int baseToughness; int currPower; int basePower; }; class Land: public Card { public: Land(); ~Land(); protected: virtual int generateMana(int); }; class Forest: public Land { public: Forest(); ~Forest(); protected: int generateMana(); }; class Creature: public Spell { public: Creature(); ~Creature(); protected: bool summoningSick; }; class Sorcery: public Spell { public: Sorcery(); ~Sorcery(); protected: }; #endif conception.h -- this is an "uber class" from which everything derives class Conception{ public: Conception(); ~Conception(); protected: char* classType; }; conception.cpp Conception::Conception{ Conception(){ classType = new char[11]; char = "Conception"; } game.cpp -- this is an incomplete class as of this code #include <iostream> #include <cctype> #include "game.h" #include "player.h" Battlefield::Battlefield(){ card = 0; } Battlefield::~Battlefield(){ delete card; } Battlefield::Battlefield(const Battlefield & to_copy){ } // =========== /* class Game(){ public: Game(); ~Game(); protected: Player** player; // for multiple players Battlefield* root; // for battlefield getPlayerMove(); // ask player what to do addToBattlefield(); removeFromBattlefield(); sendAttack(); } */ #endif game.h #ifndef GAME_H #define GAME_H #include "list.h" class CardList(); class Battlefield : CardList{ public: Battlefield(); ~Battlefield(); protected: Card* card; // make an array }; class Game : Conception{ public: Game(); ~Game(); protected: Player** player; // for multiple players Battlefield* root; // for battlefield getPlayerMove(); // ask player what to do addToBattlefield(); removeFromBattlefield(); sendAttack(); Battlefield* field; }; list.cpp #include <iostream> #include <cctype> #include "list.h" // ========== LinkedList::LinkedList(){ root = new Node; classType = new char[strlen("LinkedList") + 1]; classType = "LinkedList"; }; LinkedList::~LinkedList(){ delete root; } LinkedList::LinkedList(const LinkedList & obj) { // code to copy } // --------- // ========= int LinkedList::delete_all(Node* root){ if (root = 0) return 0; delete_all(root->next); root = 0; } int LinkedList::add( Conception*& is){ if (root == 0){ root = new Node; root->next = 0; } else { Node * curr = root; root = new Node; root->next=curr; root->it = is; } } int LinkedList::remove(Node * root, Node * prev, Conception* is){ if (root = 0) return -1; if (root->it == is){ root->next = root->next; return 0; } remove(root->next, root, is); return 0; } Conception* LinkedList::find(Node*& root, const Conception* is, Conception* holder = NULL) { if (root==0) return NULL; if (root->it == is){ return root-> it; } holder = find(root->next, is); return holder; } Node* LinkedList::goForward(Node * root){ if (root==0) return root; if (root->next == 0) return root; else return root->next; } // ============ Node* LinkedList::goBackward(Node * root){ root = root->prev; } list.h #ifndef LIST_H #define LIST_H #include <iostream> #include "conception.h" class Node : public Conception { public: Node() : next(0), prev(0), it(0) { it = 0; classType = new char[strlen("Node") + 1]; classType = "Node"; }; ~Node(){ delete it; delete next; delete prev; } Node* next; Node* prev; Conception* it; // generic object }; // ---------------------- class LinkedList : public Conception { public: LinkedList(); ~LinkedList(); LinkedList(const LinkedList&); friend bool operator== (Conception& thing_1, Conception& thing_2 ); protected: virtual int delete_all(Node*); virtual int add( Conception*& ); // virtual Conception* find(Node *&, const Conception*, Conception* ); // virtual int remove( Node *, Node *, Conception* ); // removes question with keyword int display_all(node*& ); virtual Node* goForward(Node *); virtual Node* goBackward(Node *); Node* root; // write copy constrcutor }; // ============= class CircularLinkedList : public LinkedList { public: // CircularLinkedList(); // ~CircularLinkedList(); // CircularLinkedList(const CircularLinkedList &); }; class DoubleLinkedList : public LinkedList { public: // DoubleLinkedList(); // ~DoubleLinkedList(); // DoubleLinkedList(const DoubleLinkedList &); protected: }; // END OF LIST Hierarchy #endif player.cpp #include <iostream> #include "player.h" #include "list.h" using namespace std; Library::Library(){ root = 0; } Library::~Library(){ delete card; } // ====DECL========= Player::~Player(){ delete fname; delete lname; delete deck; } Wizard::~Wizard(){ delete mana; delete rootL; delete rootH; } // =====Player====== void Player::changeName(const char[] first, const char[] last){ char* backup1 = new char[strlen(fname) + 1]; strcpy(backup1, fname); char* backup2 = new char[strlen(lname) + 1]; strcpy(backup1, lname); if (first != NULL){ fname = new char[strlen(first) +1]; strcpy(fname, first); } if (last != NULL){ lname = new char[strlen(last) +1]; strcpy(lname, last); } return 0; } // ========== void Player::seeStats(Stats*& to_put){ to_put->wins = stats->wins; to_put->losses = stats->losses; to_put->winRatio = stats->winRatio; } // ---------- void Player::displayDeck(const LinkedList* deck){ } // ================ void CardList::findCard(Node* root, int id, NodeCard*& is){ if (root == NULL) return; if (root->it.id == id){ copyCard(root->it, is); return; } else findCard(root->next, id, is); } // -------- void CardList::deleteAll(Node* root){ if (root == NULL) return; deleteAll(root->next); root->next = NULL; } // --------- void CardList::removeCard(Node* root, int id){ if (root == NULL) return; if (root->id = id){ root->prev->next = root->next; // the prev link of root, looks back to next of prev node, and sets to where root next is pointing } return; } // --------- void CardList::addCard(Card* to_add){ if (!root){ root = new Node; root->next = NULL; root->prev = NULL; root->it = &to_add; return; } else { Node* original = root; root = new Node; root->next = original; root->prev = NULL; original->prev = root; } } // ----------- void CardList::displayAll(Node*& root){ if (root == NULL) return; cout << "Card Name: " << root->it.cardName; cout << " || Type: " << root->it.type << endl; cout << " --------------- " << endl; if (root->classType == "Spell"){ cout << "Base Power: " << root->it.basePower; cout << " || Current Power: " << root->it.currPower << endl; cout << "Base Toughness: " << root->it.baseToughness; cout << " || Current Toughness: " << root->it.currToughness << endl; } cout << "Card Type: " << root->it.currPower; cout << " || Card Color: " << root->it.color << endl; cout << "Mana Cost" << root->it.manaCost << endl; cout << "Keywords: " << root->it.keywords << endl; cout << "Flavor Text: " << root->it.flavorText << endl; cout << " ----- Class Type: " << root->it.classType << " || ID: " << root->it.id << " ----- " << endl; cout << " ******************************************" << endl; cout << endl; // ------- void CardList::copyCard(const Card& to_get, Card& put_to){ put_to.type = to_get.type; put_to.color = to_get.color; put_to.manaCost = to_get.manaCost; put_to.inPlay = to_get.inPlay; put_to.tapped = to_get.tapped; put_to.class = to_get.class; put_to.id = to_get.id; put_to.enchanted = to_get.enchanted; put_to.artifact = to_get.artifact; put_to.class = to_get.class; put.to.abilities = new char[strlen(to_get.abilities) +1]; strcpy(put_to.abilities, to_get.abilities); put.to.keywords = new char[strlen(to_get.keywords) +1]; strcpy(put_to.keywords, to_get.keywords); put.to.flavorText = new char[strlen(to_get.flavorText) +1]; strcpy(put_to.flavorText, to_get.flavorText); if (to_get.class = "Spell"){ put_to.baseToughness = to_get.baseToughness; put_to.basePower = to_get.basePower; put_to.currToughness = to_get.currToughness; put_to.currPower = to_get.currPower; } } // ---------- player.h #ifndef player.h #define player.h #include "list.h" // ============ class CardList() : public LinkedList(){ public: CardList(); ~CardList(); protected: virtual void findCard(Card&); virtual void addCard(Card* ); virtual void removeCard(Node* root, int id); virtual void deleteAll(); virtual void displayAll(); virtual void copyCard(const Conception*, Node*&); Node* root; } // --------- class Library() : public CardList(){ public: Library(); ~Library(); protected: Card* card; int numCards; findCard(Card&); // get Card and fill empty template } // ----------- class Deck() : public CardList(){ public: Deck(); ~Deck(); protected: enum deckColor { WHITE, BLUE, BLACK, RED, GREEN, MIXED }; char* deckName; } // =============== class Mana(int amount) : public Conception { public: Mana() : displayTotal(0), classType(0) { displayTotal = 0; classType = new char[strlen("Mana") + 1]; classType = "Mana"; }; protected: int accrued; void add(); void remove(); int displayTotal(); } inline Mana::add(){ accrued += 1; } inline Mana::remove(){ accrued -= 1; } inline Mana::displayTotal(){ return accrued; } // ================ class Stats() : public Conception { public: friend class Player; friend class Game; Stats() : wins(0), losses(0), winRatio(0) { wins = 0; losses = 0; if ( (wins + losses != 0) winRatio = wins / (wins + losses); else winRatio = 0; classType = new char[strlen("Stats") + 1]; classType = "Stats"; } protected: int wins; int losses; float winRatio; void int getStats(Stats*& ); } // ================== class Player() : public Conception{ public: Player() : wins(0), losses(0), winRatio(0) { fname = NULL; lname = NULL; stats = NULL; CardList = NULL; classType = new char[strlen("Player") + 1]; classType = "Player"; }; ~Player(); Player(const Player & obj); protected: // member variables char* fname; char* lname; Stats stats; // holds previous game statistics CardList* deck[]; // hold multiple decks that player might use - put ll in this private: // member functions void changeName(const char[], const char[]); void shuffleDeck(int); void seeStats(Stats*& ); void displayDeck(int); chooseDeck(); } // -------------------- class Wizard(Card) : public Player(){ public: Wizard() : { mana = NULL; rootL = NULL; rootH = NULL}; ~Wizard(); protected: playCard(const Card &); removeCard(Card &); attackWithCard(Card &); enchantWithCard(Card &); disenchantWithCard(Card &); healWithCard(Card &); equipWithCard(Card &); Mana* mana[]; Library* rootL; // Library Library* rootH; // Hand } #endif

    Read the article

  • Is there some way to make variables like $a and $b in regard to strict?

    - by Axeman
    In light of Michael Carman's comment, I have decided to rewrite the question. Note that 11 comments appear before this edit, and give credence to Michael's observation that I did not write the question in a way that made it clear what I was asking. Question: What is the standard--or cleanest way--to fake the special status that $a and $b have in regard to strict by simply importing a module? First of all some setup. The following works: #!/bin/perl use strict; print "\$a=$a\n"; print "\$b=$b\n"; If I add one more line: print "\$c=$c\n"; I get an error at compile time, which means that none of my dazzling print code gets to run. If I comment out use strict; it runs fine. Outside of strictures, $a and $b are mainly special in that sort passes the two values to be compared with those names. my @reverse_order = sort { $b <=> $a } @unsorted; Thus the main functional difference about $a and $b--even though Perl "knows their names"--is that you'd better know this when you sort, or use some of the functions in List::Util. It's only when you use strict, that $a and $b become special variables in a whole new way. They are the only variables that strict will pass over without complaining that they are not declared. : Now, I like strict, but it strikes me that if TIMTOWTDI (There is more than one way to do it) is Rule #1 in Perl, this is not very TIMTOWDI. It says that $a and $b are special and that's it. If you want to use variables you don't have to declare $a and $b are your guys. If you want to have three variables by adding $c, suddenly there's a whole other way to do it. Nevermind that in manipulating hashes $k and $v might make more sense: my %starts_upper_1_to_25 = skim { $k =~ m/^\p{IsUpper}/ && ( 1 <= $v && $v <= 25 ) } %my_hash ;` Now, I use and I like strict. But I just want $k and $v to be visible to skim for the most compact syntax. And I'd like it to be visible simply by use Hash::Helper qw<skim>; I'm not asking this question to know how to black-magic it. My "answer" below, should let you know that I know enough Perl to be dangerous. I'm asking if there is a way to make strict accept other variables, or what is the cleanest solution. The answer could well be no. If that's the case, it simply does not seem very TIMTOWTDI.

    Read the article

  • A Surface view and a canvas to move Bitmap

    - by John Apple Sim
    I have a SurfaceView and I want the Bitmap Logo inside it in the canvas to be movable What I'm doing wrong ? static float x, y; Bitmap logo; SurfaceView ss = (SurfaceView) findViewById(R.id.svSS); logo = BitmapFactory.decodeResource(getResources(), R.drawable.logo); x = 40; y = 415; ss.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent me) { try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } switch(me.getAction()) { case MotionEvent.ACTION_DOWN: x = me.getX(); y = me.getY(); break; case MotionEvent.ACTION_UP: x = me.getX(); y = me.getY(); break; case MotionEvent.ACTION_MOVE: x = me.getX(); y = me.getY(); break; } return true; } }); public class OurView extends SurfaceView implements Runnable{ Thread t = null; SurfaceHolder holder; boolean isItOK = false; public OurView(Context context) { super(context); holder = getHolder(); } public void run (){ while (isItOK == true){ //canvas DRAWING if (!holder.getSurface().isValid()){ continue; } Canvas c = holder.lockCanvas(); c.drawARGB(255, 200, 100, 100); c.drawBitmap(logo, x,y,null); holder.unlockCanvasAndPost(c); } } public void pause(){ isItOK = false; while(true){ try { t.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } t = null; } public void resume(){ isItOK = true; t = new Thread(this); t.start(); } } Now the surface view is just black .. nothing happens also its not colored 200, 100, 100

    Read the article

  • Special parameters for texture binding?

    - by user146780
    Do I have to set up my gl context in a certain way to bind textures. I'm following a tutorial. I start by doing: #define checkImageWidth 64 #define checkImageHeight 64 static GLubyte checkImage[checkImageHeight][checkImageWidth][4]; static GLuint texName; void makeCheckImage(void) { int i, j, c; for (i = 0; i < checkImageHeight; i++) { for (j = 0; j < checkImageWidth; j++) { c = ((((i&0x8)==0)^((j&0x8))==0))*255; checkImage[i][j][0] = (GLubyte) c; checkImage[i][j][1] = (GLubyte) c; checkImage[i][j][2] = (GLubyte) c; checkImage[i][j][3] = (GLubyte) 255; } } } void initt(void) { glClearColor (0.0, 0.0, 0.0, 0.0); makeCheckImage(); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glGenTextures(1, &texName); glBindTexture(GL_TEXTURE_2D, texName); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage); engineGL.current.tex = texName; } In my rendering I do: PolygonTesselator.Begin_Contour(); glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); glBindTexture(GL_TEXTURE_2D, current.tex); if(layer[currentlayer].Shapes[i].Contour[c].DrawingPoints.size() > 0) { glColor4f( layer[currentlayer].Shapes[i].Color.r, layer[currentlayer].Shapes[i].Color.g, layer[currentlayer].Shapes[i].Color.b, layer[currentlayer].Shapes[i].Color.a); } for(unsigned int j = 0; j < layer[currentlayer].Shapes[i].Contour[c].DrawingPoints.size(); ++j) { gluTessVertex(PolygonTesselator.tobj,&layer[currentlayer].Shapes[i].Contour[c].DrawingPoints[j][0], &layer[currentlayer].Shapes[i].Contour[c].DrawingPoints[j][0]); } PolygonTesselator.End_Contour(); } glDisable(GL_TEXTURE_2D); } However it still renders the color and not the texture at all. I'd atleast expect to see black or something but its as if the bind fails. Am I missing something? Thanks

    Read the article

  • Calling back a functions value

    - by Jason Kelly
    I need your help, I cannot, for the life of me, figure this out. I've had my head wrapped around it only to no avail. Ideally, i'd like to setup two functions. 1 function: select_date() to interact with the user to select a date from the jQuery Date picker. If the dialog is closed then return as null. Then a second function: test() to check wether or not a date was picked/selected.' Here's my delema, when the function test() is executed, an alert box pops up and says "undefined" which means, I never get to select a date and it always being "undefined" I dont see what I am doing wrong here and everything seems logical to me. <!DOCTYPE html> <html> <head> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.js"></script> <script type="text/javascript"> function select_date() { var sdate $('#dd').dialog({ autoOpen: true, modal: true, overlay: { opacity: 0.5, background: 'black' }, title: "title", height: 265, width: 235, draggable: false, resizable: false }); $('#d1').datepicker({ onSelect: function () { $("#dd").dialog("close"); } }); return sdate } function test() { var x = select_date() alert(x) } </script> <style type="text/css"> #d1 {font-size:64%;} </style> </head> <body> <div id="dd"> <div id="d1"> </div> </div> <a href="javascript:test()">test</a> </body> </html>

    Read the article

  • ListBox content does not resize when window is made smaller

    - by DamonGant
    I'm using .NET 4.0 (not .NET 4.0 CP) and have run into this kinda unique issue. I created a ListBox to display bound elements, first off here is (a part) of my XAML. <Grid Grid.Row="2" Background="#EEEEEE"> <Border Margin="6,10,10,10" BorderBrush="#666666" BorderThickness="1"> <ListBox ItemsSource="{Binding}" Name="appList" BorderThickness="0" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch"> <ItemsControl.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="80" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Border Grid.Column="0" Margin="5" BorderThickness="3" CornerRadius="2" BorderBrush="Black" HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="ItemBorder"> <Image Width="64" Height="64" Source="{Binding Path=IconUri}" Stretch="UniformToFill" /> </Border> <StackPanel Margin="0,5,5,5" Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Stretch"> <TextBlock FontSize="18" Text="{Binding Path=DisplayName}" /> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="60"/> </Grid.ColumnDefinitions> <ProgressBar Grid.Column="0" Height="24" HorizontalAlignment="Stretch" IsIndeterminate="{Binding Path=IsDiscovering}" Value="{Binding Path=PercentageDownloaded}" /> <TextBlock Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"><TextBlock x:Name="percentageDownloaded" /><TextBlock x:Name="percentageMeter">%</TextBlock></TextBlock> </Grid> </StackPanel> </Grid> <DataTemplate.Triggers> <DataTrigger Binding="{Binding Path=IsDiscovering}"> <DataTrigger.Value>True</DataTrigger.Value> <Setter TargetName="percentageDownloaded" Property="Text" Value="N/A" /> <Setter TargetName="percentageMeter" Property="Visibility" Value="Collapsed" /> </DataTrigger> <DataTrigger Binding="{Binding Path=IsDiscovering}"> <DataTrigger.Value>False</DataTrigger.Value> <Setter TargetName="percentageDownloaded" Property="Text" Value="{Binding Path=PercentageDownloaded}" /> <Setter TargetName="percentageMeter" Property="Visibility" Value="Visible" /> </DataTrigger> </DataTemplate.Triggers> </DataTemplate> </ItemsControl.ItemTemplate> </ListBox> </Border> </Grid> Sizing the window up stretches the ListBox content just fine, but when I size it down, it retains it's width and spawns vertical scrollbars.

    Read the article

  • Get content in iframe to use as much space as it needs

    - by Mark
    I'm trying to write a simple JavaScript based modal dialog. The JavaScript function takes the content, puts it in a new iframe and adds the iframe to the page. Works great so far, the only problem is that the content of the dialog (e.g. a table) gets wrapped, although plenty of space is available on the page. I'd like the content of the dialog, a table in my case, to use as much space as it needs, without wrapping any lines. I tried lots of combinations of setting width/style.width on the iframe and the table. Nothing did the trick. Here the code to show the iframe dialog: function SimpleDialog() { this.domElement = document.createElement('iframe'); this.domElement.setAttribute('style', 'border: 1px solid red; z-index: 201; position: absolute; top: 0px; left: 0px;'); this.showWithContent = function(content) { document.getElementsByTagName('body')[0].appendChild(this.domElement); this.domElement.contentDocument.body.appendChild(content); var contentBody = this.domElement.contentDocument.body; contentBody.style.padding = '0px'; contentBody.style.margin = '0px'; // Set the iframe size to the size of content. // However, content got wrapped already. this.domElement.style.height = content.offsetHeight + 'px'; this.domElement.style.width = content.offsetWidth + 'px'; this._centerOnScreen(); }; this._centerOnScreen = function() { this.domElement.style.left = window.pageXOffset + (window.innerWidth / 2) - (this.domElement.offsetWidth / 2) + 'px'; this.domElement.style.top = window.pageYOffset + (window.innerHeight / 2) - (this.domElement.offsetHeight / 2) + 'px'; }; } Here the test code: var table = document.createElement('table'); table.setAttribute('style', 'border: 1px solid black; width: 100%;'); table.innerHTML = "<tr><td style='font-size:40px;'>Hello world in big letters</td></tr><tr><td>second row</td></tr>"; var dialog = new SimpleDialog(); dialog.showWithContent(table); The table shows up nicely centered on the page, but the words in the first cell are wrapped to two lines. How do I get the table to use as much space as it needs (without using white-space: nowrap ;) Thanks in advance for any suggestions! -Mark

    Read the article

  • Browsers (IE and Firefox) freeze when copying large amount of text

    - by Matt
    I have a web application - a Java servlet - that delivers data to users in the form of a text printout in a browser (text marked up with HTML in order to display in the browser as we want it to). The text does display in different colors, though most of it is black. One typical mode of operation is this: 1. User submits a form to request data. 2. Servlet delivers HTML file to browser. 3. User does CTRL+A to select all the text. 4. User does CTRL+C to copy all the text. 5. User goes to a text editor and does CTRL+V to paste the text. In the testing where I'm having this problem, step #2 successfully loads all the data - we wait for that to complete. We can scroll down to the end of what the browser loaded and see the end of the data. However, the browser freezes on step #3 (Firefox) or on step #4 (IE). Because step #2 finishes, I think it is a browser/memory issue, and not an issue with the web application. If I run queries to deliver smaller amounts of data (but after several queries we get the same data we would have above in one query) and copy/paste this text, the file I save it into ends up being about 8 MB. If I save the browser's displayed HTML to a file on my computer via File-Save As from the browser menu, it works fine and the file is about 22 MB. We've tried this on 2 different computers at work (both running Windows XP, with at least 2 GB of RAM and many GB of free disk space), using Firefox and IE. We also tried it on a home computer from a home network outside of work (thinking it might be our IT security software causing the problem), running Windows 7 using IE, and still had the problem. When I've done this, I can see whatever browser I'm using utilizing the CPU at 50%. Firefox's memory usage grows to about 1 GB; IE's stays in the several hundred MBs. We once let this run for half an hour, and it did not complete. I'm most likely going to modify the web app to have an option of delivering a plain text file for download, and I imagine that will get the users what they need. But for the mean time, and because I'm curious - and I don't like my application freezing people's browsers, does anyone have any ideas about the browser freezing? I understand that sometimes you just reach your memory limit, but 22 MB sounds to me like an amount I should be able to copy to the clipboard.

    Read the article

  • What's causing this background-image to display "incorrectly" in Opera and Firefox?

    - by Sukasa
    I know this is something I'm probably doing wrong, so please don't incinerate me for the thread title. I'm trying to put together a small personal website using HTML 5/CSS3. I've checked with the w3c validator and the site and CSS file fully conform according to the validator (However the validator has a warning attached that it might not be perfect). I'm not sure how to explain it without a picture, so here's a comparison of Chrome/Opera/Firefox: So, you can sorta see how in Chrome the background image is in one non-repeating piece, whereas in Opera/Firefox the image has, oddly, been broken up and placed slightly differently. I'm confident this is due to an error on my part, but I've had no luck at all figuring out why the image is being mangled in Opera and Firefox. Here's the CSS that's relevant to this issue: /* Content Pane */ .content { position: absolute; left: 220px; width: 800px; top: 80px; min-height: 550px; background-color: rgba(8,12,42,0.85); } /* Headers */ .content hgroup { background: url("Header_Flat.png") no-repeat left top; min-height: 38px; padding-left: 28px; text-shadow: 0 0 8px #FFA9FF; color: Black; text-decoration: none; } .content hgroup h1 { display: block; } .content hgroup h3 { display: inline; position: relative; top: -12px; left: 20px; text-shadow: 0 0 6px #AFF9FF; } .content hgroup h4 { display: inline; position: relative; top: -12px; left: 20px; font-size: xx-small; text-shadow: 0 0 6px #AFF9FF; } And the HTML: <hgroup> <h1>New Site!</h1> <h3>Now with Bloom!</h3> <h4> - Posted Tuesday, May 11th 2010</h4> </hgroup> Can anyone see what I'm doing wrong?

    Read the article

  • Updating Textures on Runtime in OpenSceneGraph

    - by Abhishek Bansal
    I am working on a project in which i am required to capture frames from external device video and render them on openSceneGraph Node. I am also using GLSL shaders. But i dont know how to update textures on runtime. For other uniforms we need to make callbacks but do we also need to make callbacks for samplers in glsl and openSceneGraph ? My code looks like this. All i am getting right now is a black window. osg::ref_ptr<osg::Geometry> pictureQuad = osg::createTexturedQuadGeometry(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(_deviceNameToImageFrameMap[deviceName].frame->s(),0.0f,0.0f), osg::Vec3(0.0f,0.0f,_deviceNameToImageFrameMap[deviceName].frame->t()), 0.0f, 1.0f,_deviceNameToImageFrameMap[deviceName].frame->s(), _deviceNameToImageFrameMap[deviceName].frame->t()); //creating texture and setting up parameters for video frame osg::ref_ptr<osg::TextureRectangle> myTex= new osg::TextureRectangle(_deviceNameToImageFrameMap[deviceName].frame.get()); myTex->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR); myTex->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR); myTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); myTex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); _videoSourceNameToNodeMap[sourceName].geode = new osg::Geode(); _videoSourceNameToNodeMap[sourceName].geode->setDataVariance(osg::Object::DYNAMIC); _videoSourceNameToNodeMap[sourceName].geode->addDrawable(pictureQuad.get()); //apply texture to node _videoSourceNameToNodeMap[sourceName].geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, myTex.get(), osg::StateAttribute::ON); _videoSourceNameToNodeMap[sourceName].geode->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); _videoSourceNameToNodeMap[sourceName].geode->setDataVariance(osg::Object::DYNAMIC); //Set uniform sampler osg::Uniform* srcFrame = new osg::Uniform( osg::Uniform::SAMPLER_2D, "srcFrame" ); srcFrame->set(0); //Set Uniform Alpha osg::Uniform* alpha = new osg::Uniform( osg::Uniform::FLOAT, "alpha" ); alpha->set(.5f); alpha->setUpdateCallback(new ExampleCallback()); //Enable blending _videoSourceNameToNodeMap[sourceName].geode->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON); //Adding blend function to node osg::BlendFunc *bf = new osg::BlendFunc(); bf->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); _videoSourceNameToNodeMap[sourceName].geode->getOrCreateStateSet()->setAttributeAndModes(bf); //apply shader to quad _videoSourceNameToNodeMap[sourceName].geode->getOrCreateStateSet()->setAttributeAndModes(program, osg::StateAttribute::ON); //add Uniform to shader _videoSourceNameToNodeMap[sourceName].geode->getOrCreateStateSet()->addUniform( srcFrame ); _videoSourceNameToNodeMap[sourceName].geode->getOrCreateStateSet()->addUniform( alpha );

    Read the article

  • How do you make the scale animation begin at the middle of the object instead of the top left?

    - by Roy
    What I am trying to accomplish: 10 percent increase scale transformation of a rectangle via Silverlight storyboard animation. What I currently doing: While in Expression Blend 3, I created a rectangle, created a storyboard, and created the scale transformation. The preview looked correct because the increase in scale begins in the middle of the object. When I run the project the scale transformation begins at the top left. Is there some piece of code missing? Here is my current code: <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="TestingGroundsWebsite.MainPage" Width="640" Height="480"> <UserControl.Resources> <Storyboard x:Name="RectangleAppear"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.1"/> <EasingDoubleKeyFrame KeyTime="00:00:01" Value="1.1"/> <EasingDoubleKeyFrame KeyTime="00:00:02" Value="1"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.1"/> <EasingDoubleKeyFrame KeyTime="00:00:01" Value="1.1"/> <EasingDoubleKeyFrame KeyTime="00:00:02" Value="1"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </UserControl.Resources> <Canvas x:Name="LayoutRoot" Background="White"> <Rectangle x:Name="rectangle" Fill="#FFE80000" Stroke="Black" Height="75" Width="76" Canvas.Left="227" Canvas.Top="167" RenderTransformOrigin="0.5,0.5"> <Rectangle.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform/> <TranslateTransform/> </TransformGroup> </Rectangle.RenderTransform> </Rectangle> </Canvas> </UserControl> Thanks

    Read the article

  • Converting text into numeric in xls using Java

    - by Work World
    When I create excel sheet through java ,the column which has number datatype in the oracle table, get converted to text format in excel.I want it to remain in the number format.Below is my code snippet for excel creation. FileWriter fw = new FileWriter(tempFile.getAbsoluteFile(),true); // BufferedWriter bw = new BufferedWriter(fw); HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("Excel Sheet"); //Column Size of excel for(int i=0;i<10;i++) { sheet.setColumnWidth((short) i, (short)8000); } String userSelectedValues=result; HSSFCellStyle style = wb.createCellStyle(); ///HSSFDataFormat df = wb.createDataFormat(); style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); //style.setDataFormat(df.getFormat("0")); HSSFFont font = wb.createFont(); font.setColor(HSSFColor.BLACK.index); font.setBoldweight((short) 700); style.setFont(font); int selecteditems=userSelectedValues.split(",").length; // HSSFRow rowhead = sheet.createRow((short)0); //System.out.println("**************selecteditems************" +selecteditems); for(int k=0; k<selecteditems;k++) { HSSFRow rowhead = sheet.createRow((short)k); if(userSelectedValues.contains("O_UID")) { HSSFCell cell0 = rowhead.createCell((short) k); cell0.setCellValue("O UID"); cell0.setCellStyle(style); k=k+1; } ///some columns here.. } int index=1; for (int i = 0; i<dataBeanList.size(); i++) { odb=(OppDataBean)dataBeanList.get(i); HSSFRow row = sheet.createRow((short)index); for(int j=0;j<selecteditems;j++) { if(userSelectedValues.contains("O_UID")) { row.createCell((short)j).setCellValue(odb.getUID()); j=j+1; } } index++; } FileOutputStream fileOut = null; try { fileOut = new FileOutputStream(path.toString()+"/temp.xls"); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { wb.write(fileOut); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { fileOut.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }

    Read the article

  • Unable to get Stencil Buffer to work in iOS 4+ (5.0 works fine). [OpenGL ES 2.0]

    - by MurderDev
    So I am trying to use a stencil buffer in iOS for masking/clipping purposes. Do you guys have any idea why this code may not work? This is everything I have associated with Stencils. On iOS 4 I get a black screen. On iOS 5 I get exactly what I expect. The transparent areas of the image I drew in the stencil are the only areas being drawn later. Code is below. This is where I setup the frameBuffer, depth and stencil. In iOS the depth and stencil are combined. -(void)setupDepthBuffer { glGenRenderbuffers(1, &depthRenderBuffer); glBindRenderbuffer(GL_RENDERBUFFER, depthRenderBuffer); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, self.frame.size.width * [[UIScreen mainScreen] scale], self.frame.size.height * [[UIScreen mainScreen] scale]); } -(void)setupFrameBuffer { glGenFramebuffers(1, &frameBuffer); glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderBuffer); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderBuffer); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthRenderBuffer); // Check the FBO. if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { NSLog(@"Failure with framebuffer generation: %d", glCheckFramebufferStatus(GL_FRAMEBUFFER)); } } This is how I am setting up and drawing the stencil. (Shader code below.) glEnable(GL_STENCIL_TEST); glDisable(GL_DEPTH_TEST); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glDepthMask(GL_FALSE); glStencilFunc(GL_ALWAYS, 1, -1); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); glColorMask(0, 0, 0, 0); glClear(GL_STENCIL_BUFFER_BIT); machineForeground.shader = [StencilEffect sharedInstance]; [machineForeground draw]; machineForeground.shader = [BasicEffect sharedInstance]; glDisable(GL_STENCIL_TEST); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDepthMask(GL_TRUE); Here is where I am using the stencil. glEnable(GL_STENCIL_TEST); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilFunc(GL_EQUAL, 1, -1); ...Draw Stuff here glDisable(GL_STENCIL_TEST); Finally here is my fragment shader. varying lowp vec2 TexCoordOut; uniform sampler2D Texture; void main(void) { lowp vec4 color = texture2D(Texture, TexCoordOut); if(color.a < 0.1) gl_FragColor = color; else discard; }

    Read the article

  • Why are my lines getting thicker and thicker?

    - by mystify
    I try to draw some lines with different colors. This code tries to draw two rectangles with 1px thin lines. However, the second rectangle is drawn with 2px width lines, while the first one is drawn with 1px width. - (void)addLineFrom:(CGPoint)p1 to:(CGPoint)p2 context:(CGContextRef)context { // set the current point CGContextMoveToPoint(context, p1.x, p1.y); // add a line from the current point to the wanted point CGContextAddLineToPoint(context, p2.x, p2.y); } - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGPoint from, to; // ----- draw outer black frame (left, bottom, right) ----- CGContextBeginPath(context); // set the color CGFloat lineColor[4] = {26.0f * colorFactor, 26.0f * colorFactor, 26.0f * colorFactor, 1.0f}; CGContextSetStrokeColor(context, lineColor); // left from = CGPointZero; to = CGPointMake(0.0f, rect.size.height); [self addLineFrom:from to:to context:context]; // bottom from = to; to = CGPointMake(rect.size.width, rect.size.height); [self addLineFrom:from to:to context:context]; // right from = to; to = CGPointMake(rect.size.width, 0.0f); [self addLineFrom:from to:to context:context]; CGContextStrokePath(context); CGContextClosePath(context); // ----- draw the middle light gray frame (left, bottom, right) ----- CGContextSetLineWidth(context, 1.0f); CGContextBeginPath(context); // set the color CGFloat lineColor2[4] = {94.0f * colorFactor, 94.0f * colorFactor, 95.0f * colorFactor, 1.0f}; CGContextSetStrokeColor(context, lineColor2); // left from = CGPointMake(200.0f, 1.0f); to = CGPointMake(200.0f, rect.size.height - 2.0f); [self addLineFrom:from to:to context:context]; // bottom from = to; to = CGPointMake(rect.size.width - 2.0f, rect.size.height - 2.0f); [self addLineFrom:from to:to context:context]; // right from = to; to = CGPointMake(rect.size.width - 2.0f, 1.0f); [self addLineFrom:from to:to context:context]; // top from = to; to = CGPointMake(1.0f, 1.0f); [self addLineFrom:from to:to context:context]; CGContextStrokePath(context); }

    Read the article

  • IE dynamic image caching issue?

    - by rdevitt
    I have an html page that is loading multiple iframes into which are embedded dynamic images created from a Tomcat server page (.jsp). This works as expected from Chrome and Firefox, but for some reason IE displays all of the images the same (as the first image). I've created an example: http://coupondiscounts.com/dev/jsImageTest.html jsImageTest.html -- This page simply loads 6 instances of the testImageFrame.html page in separate iframes one-at-a-time, using Javascript. testImageFrame.html -- This is the page loaded in all the iframes. It contains only a JavaScript block that writes out the current time and an img tag. The img is dynamically generated by a .jsp page on a different server. It should be a white box on a black background. In the box are the current time (from the Tomcat server using Java) and a randomly created double between 0 & 1. What happens (in IE): The page almost instantly loads four identical iframes. Depending on the speed of your machine, the JavaScript times may vary by a second or two. The images' times will all be the same as will be the random number. This holds true even for the last two iframes which are loaded 5 and 10 seconds after the others (using JavaScript setTimeout()). What should happen (as it does in Chrome and FF): The page loads the same 4 iframes, but the random numbers in the images will be different. The times in the images occasionally span a second as well. Anyone have a clue as to what's going on here? Is IE doing some strange caching? The image header has "no-cache," "no-store" and all that. I've tried it on IE6 and 7. You can use the "Next" button to create another iframe. In IE, the images are always the same. Notes: I don't really need iframes, just the images, but if I only use img tags, the problem appears in Chrome and FF as well. I also don't really need to load these iframes dynamically, I was just trying to abstract the issue further and allow a delayed load for the latter 2 images.

    Read the article

  • Painting component inside another component

    - by mike_hornbeck
    I've got a task to display painted 'eyes' with menu buttons to change their colors, and background color. Next animate them. But currently I'm stuck at painting, sinc in my JFrame I've Created JPanel containing panels with drawn eyes and buttons. Buttons are rendered properly but my eyes canvas is not shown. I've tried changing paint to paintComponent, setting contentPane differently but still nothing works. import java.awt.*; import javax.swing.*; public class Main extends JFrame { public static void main(String[] args) { final JFrame frame = new JFrame("Eyes"); frame.setPreferredSize(new Dimension(600, 450)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel players = new JPanel(new GridLayout(1, 3)); players.add(new JButton("Eyes color")); players.add(new JButton("Eye pupil")); players.add(new JButton("Background color")); JPanel eyes = new JPanel(); Eyes e = new Eyes(); eyes.add(e); eyes.setPreferredSize(new Dimension(600, 400)); JPanel content = new JPanel(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); frame.setContentPane(content); content.add(players); content.add(eyes); // frame.getContentPane().add(content); frame.pack(); frame.setVisible(true); } } class Eyes extends JPanel { public Eyes(){ } public void paint(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); BasicStroke bs = new BasicStroke(3.0f); g2d.setBackground(Color.green); g2d.setStroke(bs); g2d.setColor(Color.yellow); g2d.fillOval(50, 150, 200, 200); g2d.fillOval( 350, 150, 200, 200); g2d.setColor(Color.BLACK); g2d.drawOval(49, 149, 201, 201); g2d.drawOval(349, 149, 201, 201); g2d.fillOval(125, 225, 50, 50); g2d.fillOval(425, 225, 50, 50); } } This is what I should get : This is what I have : When I've tried painting it directly in JFrame it works almost perfect, apart of background not being set. Why setBackgroundColor doesn't influence my drawing in any way ?

    Read the article

  • Painted JPanel won't show up in JFrame

    - by javawarrior
    When I run my code, I expect to see a JPanel in my JFrame, but nothing shows up. I had a button in the frame, and it shows up. But the JPanel doesn't show up, I even colored it in red. Here is the code for my JPanel: import java.awt.*; import javax.swing.JPanel; public class graphic extends JPanel { private static final long serialVersionUID = -3458717449092499931L; public Game game; public graphic(Game game){ this.game = game; this.setPreferredSize(new Dimension(400,400)); this.setBackground(Color.RED); } public void paintComponent(Graphics g){ for (Line l:game.mirrors){ g.setColor(Color.BLACK); g.drawLine(l.start.x, l.start.y, l.end.x, l.end.y); } } } And my JFrame code: import java.awt.Container; import java.awt.event.*; import java.util.Timer; import java.util.TimerTask; import javax.swing.*; public class Viewer implements ActionListener { public JFrame frame; public JButton drawShoot; public boolean draw; public Game game; public graphic graphic; public TimerTask timert; public Timer timer; public Viewer(){ draw = true; game = new Game(); } public static void main(String args[]){ Viewer v = new Viewer(); v.setup(); } public void setup(){ frame = new JFrame("Laser Stimulator"); drawShoot = new JButton("Edit Mode"); graphic = new graphic(game); graphic.repaint(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(300, 300, 600, 600); Container contentPane = frame.getContentPane(); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout); drawShoot.addActionListener(this); timert = new TimerTask() { @Override public void run() { } }; timer =new Timer(); timer.scheduleAtFixedRate(timert, 0, 1000/30); contentPane.add(graphic); layout.putConstraint(SpringLayout.NORTH, graphic, 0, SpringLayout.NORTH, contentPane); layout.putConstraint(SpringLayout.WEST, graphic, 0, SpringLayout.WEST, contentPane); frame.setVisible(true); } @Override public void actionPerformed(ActionEvent e) { if (e.getSource()==drawShoot){ draw = !draw; drawShoot.setText((draw)?"Edit Mode":"Shoot Mode"); } } }

    Read the article

  • Why is my custom view not appearing?

    - by user351469
    When I comment out setContentView(boardView); in my Game.java my custom view in BoardView works fine and displays everything nicely... but onSizeChanged never gets called in BoardView.java... so I can't read the device width and height at runtime. If I leave setContentView uncommented onSizeChanged works... but the screen is blank! I want to be able to read the screen width and height at runtime and set the sizes of my ImageViews at creation so they are the optimal size. public class Game extends Activity implements OnClickListener{ private BoardView boardView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); boardView = new BoardView(this); setContentView(boardView); // when this line disabled, it looks ok boardView.requestFocus(); } public class BoardView extends View { private final Game game; private float width; // width of one unit private float height; // height of one unit public BoardView(Context context){ super(context); this.game = (Game)context; setFocusable(true); setFocusableInTouchMode(true); LinearLayout maincontainer = new LinearLayout(game); maincontainer.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); maincontainer.setGravity(Gravity.CENTER); maincontainer.setOrientation(LinearLayout.VERTICAL); maincontainer.setBackgroundColor(Color.BLACK); LinearLayout innercontainer = new LinearLayout(game); innercontainer.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); innercontainer.setGravity(Gravity.CENTER); innercontainer.setOrientation(LinearLayout.HORIZONTAL); // declare a new table TableLayout layout = new TableLayout(game); layout.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); // build a grid of ImageViews in a TableLayout for (int f=1; f<=7; f++) { TableRow tr = new TableRow(game); for (int c=1; c<=7; c++) { ImageView b = new ImageView(game); b.setImageResource(R.drawable.neworb); b.setOnClickListener(game); tr.addView(b, 30,30); // I'd like to not use fixed values here } // for layout.addView(tr); } // for innercontainer.addView(layout); maincontainer.addView(innercontainer); game.setContentView(maincontainer); } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh){ width = w/9f; height = width; super.onSizeChanged(w, h, oldw, oldh); } }

    Read the article

  • need help in positioning

    - by teki
    i am using "beassistance validation" for my form and using tooltip plugin and it work fine except that positioning. please have a look at this link and i upload my form to get an idea what i am talking about. what i want is: if my validation fails i want to display the message after the tooltip icon, but its displaying the message before the tooltip icon. please see here here is the .css i am using: validation .css #aspnetForm { width: 670px; } #aspnetForm label.error { margin-left: 10px; width: auto; display: inline; } form.cmxform { width: 50em; } em.error { background: url("Images/unchecked.gif") no-repeat 0px 0px; padding-left: 16px; } em.success { background: url("Images/checked.gif") no-repeat 0px 0px; padding-left: 16px; } form.cmxform label.error { margin-left: auto; width: 250px; } #aspnetForm label.error { background: url("Images/unchecked.gif") no-repeat 0px 0px; padding-left: 16px; padding-bottom: 2px; font-weight: bold; color: #EA5200; } #aspnetForm label.checked { background: url("Images/checked.gif") no-repeat 0px 0px; } em.error { color: black; } #warning { display: none; } <asp:Label runat="server" ID='Label8' >Start Date:</asp:Label> <asp:TextBox ID="txtStartDate" runat='server' ></asp:TextBox> <a style="cursor: hand" class="tooltip" title="Select the starting date of a visit, example 05/05/2010 (MM/DD/YYYY)!"> <img alt="" src="Scripts/JQuery/Tooltip/icon_tooltip.gif" style="width: 11px; height: 11px" /></a> <p> </p> <asp:Label runat="server" ID='Label9' >End Date:</asp:Label> <asp:TextBox ID="txtEndDate" runat='server' ></asp:TextBox> <a style="cursor: hand" class="tooltip" title="Select the end date of a visit, example 05/06/2010 (MM/DD/YYYY)!"> <img alt="" src="Scripts/JQuery/Tooltip/icon_tooltip.gif" style="width: 11px; height: 11px" /></a> tooltip.css #tooltip{ position:absolute; border:1px solid #333; background:#f7f5d1; padding:2px 5px; color:#333; display:none; }

    Read the article

< Previous Page | 164 165 166 167 168 169 170 171 172 173 174 175  | Next Page >